diff --git a/build.gradle b/build.gradle index c8f6e725a5..a986b4e058 100644 --- a/build.gradle +++ b/build.gradle @@ -325,7 +325,7 @@ project(":tools"){ implementation arcModule("natives:natives-box2d-desktop") implementation arcModule("backends:backend-headless") - implementation "org.reflections:reflections:0.9.12" + implementation "org.reflections:reflections:0.9.11" } } diff --git a/core/assets-raw/sprites/units/weapons/artillery.png b/core/assets-raw/sprites/units/weapons/artillery.png index 27572467bf..fe8369d27a 100644 Binary files a/core/assets-raw/sprites/units/weapons/artillery.png and b/core/assets-raw/sprites/units/weapons/artillery.png differ diff --git a/core/assets-raw/sprites/units/weapons/beam-weapon.png b/core/assets-raw/sprites/units/weapons/beam-weapon.png index 0e802877f7..d4784aa69f 100644 Binary files a/core/assets-raw/sprites/units/weapons/beam-weapon.png and b/core/assets-raw/sprites/units/weapons/beam-weapon.png differ diff --git a/core/assets-raw/sprites/units/weapons/chaos.png b/core/assets-raw/sprites/units/weapons/chaos.png index 9c7f91085c..442d5b0417 100644 Binary files a/core/assets-raw/sprites/units/weapons/chaos.png and b/core/assets-raw/sprites/units/weapons/chaos.png differ diff --git a/core/assets-raw/sprites/units/weapons/eradication.png b/core/assets-raw/sprites/units/weapons/eradication.png index 15a7748677..231158b058 100644 Binary files a/core/assets-raw/sprites/units/weapons/eradication.png and b/core/assets-raw/sprites/units/weapons/eradication.png differ diff --git a/core/assets-raw/sprites/units/weapons/eruption.png b/core/assets-raw/sprites/units/weapons/eruption.png index d17685fc57..713b5c0c4a 100644 Binary files a/core/assets-raw/sprites/units/weapons/eruption.png and b/core/assets-raw/sprites/units/weapons/eruption.png differ diff --git a/core/assets-raw/sprites/units/weapons/flakgun.png b/core/assets-raw/sprites/units/weapons/flakgun.png index e73c50aed2..12ee89862f 100644 Binary files a/core/assets-raw/sprites/units/weapons/flakgun.png and b/core/assets-raw/sprites/units/weapons/flakgun.png differ diff --git a/core/assets-raw/sprites/units/weapons/flamethrower.png b/core/assets-raw/sprites/units/weapons/flamethrower.png index 8887f4296d..6aac73acd3 100644 Binary files a/core/assets-raw/sprites/units/weapons/flamethrower.png and b/core/assets-raw/sprites/units/weapons/flamethrower.png differ diff --git a/core/assets-raw/sprites/units/weapons/heal-weapon-mount.png b/core/assets-raw/sprites/units/weapons/heal-weapon-mount.png index cebc522f86..2ff4d59c4a 100644 Binary files a/core/assets-raw/sprites/units/weapons/heal-weapon-mount.png and b/core/assets-raw/sprites/units/weapons/heal-weapon-mount.png differ diff --git a/core/assets-raw/sprites/units/weapons/heal-weapon.png b/core/assets-raw/sprites/units/weapons/heal-weapon.png index e7b61dd884..3a89ba245f 100644 Binary files a/core/assets-raw/sprites/units/weapons/heal-weapon.png and b/core/assets-raw/sprites/units/weapons/heal-weapon.png differ diff --git a/core/assets-raw/sprites/units/weapons/large-weapon.png b/core/assets-raw/sprites/units/weapons/large-weapon.png index b93338cfca..426fbfc470 100644 Binary files a/core/assets-raw/sprites/units/weapons/large-weapon.png and b/core/assets-raw/sprites/units/weapons/large-weapon.png differ diff --git a/core/assets-raw/sprites/units/weapons/lich-missiles.png b/core/assets-raw/sprites/units/weapons/lich-missiles.png index d8fbd8549b..a37cbfa449 100644 Binary files a/core/assets-raw/sprites/units/weapons/lich-missiles.png and b/core/assets-raw/sprites/units/weapons/lich-missiles.png differ diff --git a/core/assets-raw/sprites/units/weapons/missiles.png b/core/assets-raw/sprites/units/weapons/missiles.png index 89e8713f23..38c0548ca6 100644 Binary files a/core/assets-raw/sprites/units/weapons/missiles.png and b/core/assets-raw/sprites/units/weapons/missiles.png differ diff --git a/core/assets-raw/sprites/units/weapons/mount-weapon.png b/core/assets-raw/sprites/units/weapons/mount-weapon.png index 2af685bf2b..3561c08013 100644 Binary files a/core/assets-raw/sprites/units/weapons/mount-weapon.png and b/core/assets-raw/sprites/units/weapons/mount-weapon.png differ diff --git a/core/assets-raw/sprites/units/weapons/revenant-missiles.png b/core/assets-raw/sprites/units/weapons/revenant-missiles.png index bc7dd1f0a5..e482202c65 100644 Binary files a/core/assets-raw/sprites/units/weapons/revenant-missiles.png and b/core/assets-raw/sprites/units/weapons/revenant-missiles.png differ diff --git a/core/assets-raw/sprites/units/weapons/small-basic-weapon.png b/core/assets-raw/sprites/units/weapons/small-basic-weapon.png index a5c7793ff2..e4833342a4 100644 Binary files a/core/assets-raw/sprites/units/weapons/small-basic-weapon.png and b/core/assets-raw/sprites/units/weapons/small-basic-weapon.png differ diff --git a/core/assets-raw/sprites/units/weapons/small-weapon.png b/core/assets-raw/sprites/units/weapons/small-weapon.png index 7d1e246dd4..ee4554082e 100644 Binary files a/core/assets-raw/sprites/units/weapons/small-weapon.png and b/core/assets-raw/sprites/units/weapons/small-weapon.png differ diff --git a/core/assets-raw/sprites/units/weapons/weapon.png b/core/assets-raw/sprites/units/weapons/weapon.png index 277fe2463e..a0c24aa143 100644 Binary files a/core/assets-raw/sprites/units/weapons/weapon.png and b/core/assets-raw/sprites/units/weapons/weapon.png differ diff --git a/core/assets-raw/sprites/weapons/beam-weapon.png b/core/assets-raw/sprites/weapons/beam-weapon.png deleted file mode 100644 index 0e802877f7..0000000000 Binary files a/core/assets-raw/sprites/weapons/beam-weapon.png and /dev/null differ diff --git a/core/assets/scripts/global.js b/core/assets/scripts/global.js index e254f4c2e7..5d2f80aec7 100755 --- a/core/assets/scripts/global.js +++ b/core/assets/scripts/global.js @@ -139,5 +139,4 @@ const ResizeEvent = Packages.mindustry.game.EventType.ResizeEvent const LaunchEvent = Packages.mindustry.game.EventType.LaunchEvent const LoseEvent = Packages.mindustry.game.EventType.LoseEvent const WinEvent = Packages.mindustry.game.EventType.WinEvent -const TurnEvent = Packages.mindustry.game.EventType.TurnEvent const Trigger = Packages.mindustry.game.EventType.Trigger diff --git a/core/assets/sprites/fallback/sprites.atlas b/core/assets/sprites/fallback/sprites.atlas index 7b5d421f21..f193607647 100644 --- a/core/assets/sprites/fallback/sprites.atlas +++ b/core/assets/sprites/fallback/sprites.atlas @@ -5659,6 +5659,13 @@ artillery orig: 48, 56 offset: 0, 0 index: -1 +beam-weapon + rotate: false + xy: 1957, 1771 + size: 80, 80 + orig: 80, 80 + offset: 0, 0 + index: -1 chaos rotate: false xy: 655, 156 @@ -5785,20 +5792,6 @@ wraith orig: 48, 48 offset: 0, 0 index: -1 -beam-weapon - rotate: false - xy: 1957, 1771 - size: 80, 80 - orig: 80, 80 - offset: 0, 0 - index: -1 -beam-weapon - rotate: false - xy: 1957, 1771 - size: 80, 80 - orig: 80, 80 - offset: 0, 0 - index: -1 sprites3.png size: 2048,1024 diff --git a/core/assets/sprites/fallback/sprites2.png b/core/assets/sprites/fallback/sprites2.png index a05f7028b8..f7d1977b7d 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 1fca65a4f8..c6deba6985 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/sprites.atlas b/core/assets/sprites/sprites.atlas index 36e382ad42..581f2da904 100644 --- a/core/assets/sprites/sprites.atlas +++ b/core/assets/sprites/sprites.atlas @@ -5653,6 +5653,13 @@ artillery orig: 48, 56 offset: 0, 0 index: -1 +beam-weapon + rotate: false + xy: 2793, 803 + size: 80, 80 + orig: 80, 80 + offset: 0, 0 + index: -1 chaos rotate: false xy: 1023, 245 @@ -5779,20 +5786,6 @@ wraith orig: 48, 48 offset: 0, 0 index: -1 -beam-weapon - rotate: false - xy: 2793, 803 - size: 80, 80 - orig: 80, 80 - offset: 0, 0 - index: -1 -beam-weapon - rotate: false - xy: 2793, 803 - size: 80, 80 - orig: 80, 80 - offset: 0, 0 - index: -1 sprites2.png size: 4096,512 diff --git a/core/assets/sprites/sprites.png b/core/assets/sprites/sprites.png index 2069ad7d94..5fb7c7357c 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 c601916b26..67f333a1de 100644 Binary files a/core/assets/sprites/sprites2.png and b/core/assets/sprites/sprites2.png differ diff --git a/core/src/mindustry/content/Blocks.java b/core/src/mindustry/content/Blocks.java index 3be6a6f0d5..1dc33382b7 100644 --- a/core/src/mindustry/content/Blocks.java +++ b/core/src/mindustry/content/Blocks.java @@ -1592,6 +1592,7 @@ public class Blocks implements ContentList{ inaccuracy = 10f; shootCone = 30f; shootSound = Sounds.shootSnap; + targetGround = false; health = 145 * size * size; }}; @@ -1660,7 +1661,8 @@ public class Blocks implements ContentList{ hasPower = true; size = 2; - force = 3f; + force = 2.5f; + scaledForce = 5f; range = 170f; damage = 0.08f; health = 160 * size * size; diff --git a/core/src/mindustry/content/UnitTypes.java b/core/src/mindustry/content/UnitTypes.java index dca93f7822..e448b6e64b 100644 --- a/core/src/mindustry/content/UnitTypes.java +++ b/core/src/mindustry/content/UnitTypes.java @@ -1,7 +1,6 @@ package mindustry.content; import arc.graphics.*; -import arc.math.*; import arc.struct.*; import mindustry.ai.types.*; import mindustry.annotations.Annotations.*; @@ -70,7 +69,7 @@ public class UnitTypes implements ContentList{ weapons.add(new Weapon("large-weapon"){{ reload = 14f; x = 4f; - alternate = true; + y = 2f; ejectEffect = Fx.shellEjectSmall; bullet = Bullets.standardCopper; }}); @@ -88,7 +87,6 @@ public class UnitTypes implements ContentList{ shootSound = Sounds.flame; shootY = 2f; reload = 14f; - alternate = true; recoil = 1f; ejectEffect = Fx.none; bullet = Bullets.basicFlame; @@ -107,8 +105,7 @@ public class UnitTypes implements ContentList{ weapons.add(new Weapon("heal-weapon"){{ shootY = 1.5f; reload = 24f; - x = 1f; - shootX = 3.5f; + x = 3.5f; alternate = false; ejectEffect = Fx.none; recoil = 2f; @@ -160,10 +157,8 @@ public class UnitTypes implements ContentList{ weapons.add(new Weapon("beam-weapon"){{ shake = 2f; shootY = 4f; - shootX = 6f; - x = 0.25f; + x = 6.5f; reload = 50f; - alternate = true; recoil = 4f; shootSound = Sounds.laser; @@ -188,7 +183,6 @@ public class UnitTypes implements ContentList{ y = 1f; x = 9f; reload = 60f; - alternate = true; recoil = 4f; shake = 2f; ejectEffect = Fx.shellEjectMedium; @@ -251,7 +245,6 @@ public class UnitTypes implements ContentList{ weapons.add(new Weapon("eruption"){{ shootY = 3f; reload = 10f; - alternate = true; ejectEffect = Fx.none; recoil = 1f; x = 7f; @@ -288,18 +281,14 @@ public class UnitTypes implements ContentList{ legSplashDamage = 32; legSplashRange = 30; - for(boolean b : Mathf.booleans){ - weapons.add( - new Weapon("missiles-mount"){{ - reload = 20f; - x = 4f * Mathf.sign(b); - rotate = true; - mirror = false; - flipSprite = !b; - shake = 1f; - bullet = Bullets.missileSwarm; - }}); - } + weapons.add( + new Weapon("missiles-mount"){{ + reload = 20f; + x = 4f; + rotate = true; + shake = 1f; + bullet = Bullets.missileSwarm; + }}); }}; wraith = new UnitType("wraith"){{ @@ -315,7 +304,6 @@ public class UnitTypes implements ContentList{ y = 0f; x = 2f; reload = 15f; - alternate = true; ejectEffect = Fx.shellEjectSmall; bullet = Bullets.standardCopper; shootSound = Sounds.shoot; @@ -338,7 +326,6 @@ public class UnitTypes implements ContentList{ shootY = 0f; reload = 12f; shootCone = 180f; - alternate = true; ejectEffect = Fx.none; inaccuracy = 15f; ignoreRotation = true; @@ -360,36 +347,31 @@ public class UnitTypes implements ContentList{ engineOffset = 12f; engineSize = 3f; - for(boolean b : Mathf.booleans){ - weapons.add( - new Weapon("revenant-missiles"){{ - reload = 70f; - x = 7f * Mathf.sign(b); - rotate = true; - mirror = false; - flipSprite = !b; - shake = 1f; + weapons.add(new Weapon("revenant-missiles"){{ + reload = 70f; + x = 7f; + rotate = true; + shake = 1f; - bullet = new MissileBulletType(2.7f, 12, "missile"){{ - width = 8f; - height = 8f; - shrinkY = 0f; - drag = -0.003f; - homingRange = 60f; - keepVelocity = false; - splashDamageRadius = 25f; - splashDamage = 10f; - lifetime = 60f; - trailColor = Pal.unitBack; - backColor = Pal.unitBack; - frontColor = Pal.unitFront; - hitEffect = Fx.blastExplosion; - despawnEffect = Fx.blastExplosion; - weaveScale = 6f; - weaveMag = 1f; - }}; - }}); - } + bullet = new MissileBulletType(2.7f, 12, "missile"){{ + width = 8f; + height = 8f; + shrinkY = 0f; + drag = -0.003f; + homingRange = 60f; + keepVelocity = false; + splashDamageRadius = 25f; + splashDamage = 10f; + lifetime = 60f; + trailColor = Pal.unitBack; + backColor = Pal.unitBack; + frontColor = Pal.unitFront; + hitEffect = Fx.blastExplosion; + despawnEffect = Fx.blastExplosion; + weaveScale = 6f; + weaveMag = 1f; + }}; + }}); }}; reaper = new UnitType("reaper"){{ @@ -407,7 +389,6 @@ public class UnitTypes implements ContentList{ weapons.add(new Weapon(){{ y = 1.5f; reload = 28f; - alternate = true; ejectEffect = Fx.shellEjectSmall; bullet = Bullets.standardCopper; shootSound = Sounds.shoot; @@ -429,7 +410,6 @@ public class UnitTypes implements ContentList{ weapons.add(new Weapon(){{ y = 1.5f; reload = 28f; - alternate = true; ejectEffect = Fx.shellEjectSmall; bullet = Bullets.standardCopper; shootSound = Sounds.shoot; @@ -445,7 +425,6 @@ public class UnitTypes implements ContentList{ weapons.add(new Weapon("mount-weapon"){{ reload = 10f; x = 1.25f; - alternate = true; rotate = true; ejectEffect = Fx.shellEjectSmall; bullet = Bullets.standardCopper; @@ -478,7 +457,6 @@ public class UnitTypes implements ContentList{ y = 1.5f; reload = 40f; x = 0.5f; - alternate = true; ejectEffect = Fx.none; recoil = 2f; bullet = Bullets.healBulletBig; @@ -506,10 +484,8 @@ public class UnitTypes implements ContentList{ weapons.add(new Weapon("small-basic-weapon"){{ reload = 15f; - x = -1f; - y = -1f; - shootX = 3.5f; - alternate = true; + x = 2.75f; + y = 1f; bullet = new BasicBulletType(2.5f, 9){{ width = 7f; @@ -551,28 +527,21 @@ public class UnitTypes implements ContentList{ hitsize = 14f; engineSize = 3f; - for(boolean b : Mathf.booleans){ - weapons.add( - new Weapon("heal-weapon-mount"){{ - reload = 25f; - x = 8f * Mathf.sign(b); - y = -6f; - rotate = true; - mirror = false; - flipSprite = !b; - bullet = Bullets.healBulletBig; - }}, - new Weapon("heal-weapon-mount"){{ - reload = 15f; - x = 4f * Mathf.sign(b); - y = 5f; - rotate = true; - mirror = false; - flipSprite = !b; - bullet = Bullets.healBullet; - }} - ); - } + weapons.add( + new Weapon("heal-weapon-mount"){{ + reload = 25f; + x = 8f; + y = -6f; + rotate = true; + bullet = Bullets.healBulletBig; + }}, + new Weapon("heal-weapon-mount"){{ + reload = 15f; + x = 4f; + y = 5f; + rotate = true; + bullet = Bullets.healBullet; + }}); }}; /* diff --git a/core/src/mindustry/entities/comp/WeaponsComp.java b/core/src/mindustry/entities/comp/WeaponsComp.java index 350b123163..664d8dd350 100644 --- a/core/src/mindustry/entities/comp/WeaponsComp.java +++ b/core/src/mindustry/entities/comp/WeaponsComp.java @@ -84,11 +84,17 @@ abstract class WeaponsComp implements Teamc, Posc, Rotc{ Weapon weapon = mount.weapon; mount.reload = Math.max(mount.reload - Time.delta(), 0); + if(weapon.otherSide != -1 && weapon.alternate && mount.side == weapon.flipSprite && + mount.reload + Time.delta() > weapon.reload/2f && mount.reload <= weapon.reload/2f){ + mounts[weapon.otherSide].side = !mounts[weapon.otherSide].side; + mount.side = !mount.side; + } + //rotate if applicable if(weapon.rotate && (mount.rotate || mount.shoot)){ - float axisXOffset = weapon.mirror ? 0f : weapon.x; + float axisXOffset = weapon.x; float axisX = this.x + Angles.trnsx(rotation, axisXOffset, weapon.y), - axisY = this.y + Angles.trnsy(rotation, axisXOffset, weapon.y); + axisY = this.y + Angles.trnsy(rotation, axisXOffset, weapon.y); mount.targetRotation = Angles.angle(axisX, axisY, mount.aimX, mount.aimY) - rotation(); mount.rotation = Angles.moveToward(mount.rotation, mount.targetRotation, weapon.rotateSpeed * Time.delta()); @@ -97,31 +103,31 @@ abstract class WeaponsComp implements Teamc, Posc, Rotc{ mount.targetRotation = angleTo(mount.aimX, mount.aimY); } - if(mount.shoot && (ammo > 0 || !state.rules.unitAmmo || team().rules().infiniteAmmo)){ + //shoot if applicable + if(mount.shoot && //must be shooting + (ammo > 0 || !state.rules.unitAmmo || team().rules().infiniteAmmo) && //check ammo + (!weapon.alternate || mount.side == weapon.flipSprite) && + mount.reload <= 0.0001f && //reload has to be 0 + Angles.within(weapon.rotate ? mount.rotation : this.rotation, mount.targetRotation, mount.weapon.shootCone) //has to be within the cone + ){ + float rotation = this.rotation - 90; + float weaponRotation = rotation + (weapon.rotate ? mount.rotation : 0); - //shoot if applicable - if(mount.reload <= 0.0001f && Angles.within(weapon.rotate ? mount.rotation : this.rotation, mount.targetRotation, mount.weapon.shootCone)){ - for(int i : (weapon.mirror && !weapon.alternate ? Mathf.signs : Mathf.one)){ - i *= Mathf.sign(weapon.flipped) * (mount.weapon.mirror ? Mathf.sign(mount.side) : 1); + //m a t h - //m a t h - float weaponRotation = rotation + (weapon.rotate ? mount.rotation : 0); - float mountX = this.x + Angles.trnsx(rotation, weapon.x * i, weapon.y), - mountY = this.y + Angles.trnsy(rotation, weapon.x * i, weapon.y); - float shootX = mountX + Angles.trnsx(weaponRotation, weapon.shootX * i, weapon.shootY), - shootY = mountY + Angles.trnsy(weaponRotation, weapon.shootX * i, weapon.shootY); - float shootAngle = weapon.rotate ? weaponRotation + 90 : Angles.angle(shootX, shootY, mount.aimX, mount.aimY) + (this.rotation - angleTo(mount.aimX, mount.aimY)); + float mountX = this.x + Angles.trnsx(rotation, weapon.x, weapon.y), + mountY = this.y + Angles.trnsy(rotation, weapon.x, weapon.y); + float shootX = mountX + Angles.trnsx(weaponRotation, weapon.shootX, weapon.shootY), + shootY = mountY + Angles.trnsy(weaponRotation, weapon.shootX, weapon.shootY); + float shootAngle = weapon.rotate ? weaponRotation + 90 : Angles.angle(shootX, shootY, mount.aimX, mount.aimY) + (this.rotation - angleTo(mount.aimX, mount.aimY)); - shoot(weapon, shootX, shootY, mount.aimX, mount.aimY, shootAngle, -i); - } + shoot(weapon, shootX, shootY, mount.aimX, mount.aimY, shootAngle, Mathf.sign(weapon.x)); - if(mount.weapon.mirror) mount.side = !mount.side; - mount.reload = weapon.reload; + mount.reload = weapon.reload; - ammo --; - if(ammo < 0) ammo = 0; - } + ammo--; + if(ammo < 0) ammo = 0; } } } @@ -145,24 +151,18 @@ abstract class WeaponsComp implements Teamc, Posc, Rotc{ Angles.shotgun(weapon.shots, weapon.spacing, rotation, f -> bullet(weapon, x, y, f + Mathf.range(weapon.inaccuracy), lifeScl)); } - Tmp.v1.trns(rotation + 180f, ammo.recoil); - if(this instanceof Velc){ - //TODO apply force? - ((Velc)this).vel().add(Tmp.v1); + ((Velc)this).vel().add(Tmp.v1.trns(rotation + 180f, ammo.recoil)); } - - Tmp.v1.trns(rotation, 3f); boolean parentize = ammo.keepVelocity; Effects.shake(weapon.shake, weapon.shake, x, y); weapon.ejectEffect.at(x, y, rotation * side); - ammo.shootEffect.at(x + Tmp.v1.x, y + Tmp.v1.y, rotation, parentize ? this : null); - ammo.smokeEffect.at(x + Tmp.v1.x, y + Tmp.v1.y, rotation, parentize ? this : null); + ammo.shootEffect.at(x, y, rotation, parentize ? this : null); + ammo.smokeEffect.at(x, y, rotation, parentize ? this : null); } private void bullet(Weapon weapon, float x, float y, float angle, float lifescl){ - Tmp.v1.trns(angle, 3f); - weapon.bullet.create(this, team(), x + Tmp.v1.x, y + Tmp.v1.y, angle, (1f - weapon.velocityRnd) + Mathf.random(weapon.velocityRnd), lifescl); + weapon.bullet.create(this, team(), x, y, angle, (1f - weapon.velocityRnd) + Mathf.random(weapon.velocityRnd), lifescl); } } diff --git a/core/src/mindustry/entities/units/WeaponMount.java b/core/src/mindustry/entities/units/WeaponMount.java index 882c850aa0..89becb6dcf 100644 --- a/core/src/mindustry/entities/units/WeaponMount.java +++ b/core/src/mindustry/entities/units/WeaponMount.java @@ -13,12 +13,12 @@ public class WeaponMount{ public float targetRotation; /** aiming position in world coordinates */ public float aimX, aimY; - /** side that's being shot - only valid for mirrors */ - public boolean side; /** whether to shoot right now */ public boolean shoot = false; /** whether to rotate to face the target right now */ public boolean rotate = false; + /** extra state for alternating weapons */ + public boolean side; public WeaponMount(Weapon weapon){ this.weapon = weapon; diff --git a/core/src/mindustry/type/UnitType.java b/core/src/mindustry/type/UnitType.java index 3a11ab7f4d..5507db7a42 100644 --- a/core/src/mindustry/type/UnitType.java +++ b/core/src/mindustry/type/UnitType.java @@ -137,6 +137,29 @@ public class UnitType extends UnlockableContent{ range = Math.max(range, weapon.bullet.range()); } } + + //add mirrored weapon variants + Seq mapped = new Seq<>(); + for(Weapon w : weapons){ + mapped.add(w); + + //mirrors are copies with X values negated + if(w.mirror){ + Weapon copy = w.copy(); + copy.x *= -1; + copy.shootX *= -1; + copy.flipSprite = !copy.flipSprite; + mapped.add(copy); + + //since there are now two weapons, the reload time must be doubled + w.reload *= 2f; + copy.reload *= 2f; + + w.otherSide = mapped.size - 1; + copy.otherSide = mapped.size - 2; + } + } + this.weapons = mapped; } @CallSuper @@ -324,23 +347,17 @@ public class UnitType extends UnlockableContent{ for(WeaponMount mount : unit.mounts){ Weapon weapon = mount.weapon; - for(int i : (weapon.mirror ? Mathf.signs : Mathf.one)){ - i *= Mathf.sign(weapon.flipped); + float rotation = unit.rotation - 90; + float weaponRotation = rotation + (weapon.rotate ? mount.rotation : 0); + float width = weapon.region.getWidth(); + float recoil = -((mount.reload) / weapon.reload * weapon.recoil); - float rotation = unit.rotation - 90; - float weaponRotation = rotation + (weapon.rotate ? mount.rotation : 0); - float width = i > 0 ? -weapon.region.getWidth() : weapon.region.getWidth(); - float recoil = -(mount.reload / weapon.reload * weapon.recoil) * (weapon.alternate ? Mathf.num(i == Mathf.sign(mount.side)) : 1); - - if(weapon.mirror) rotation = weaponRotation; - - Draw.rect(weapon.region, - unit.x + Angles.trnsx(rotation, weapon.x * i, weapon.y) + Angles.trnsx(weaponRotation, 0, recoil), - unit.y + Angles.trnsy(rotation, weapon.x * i, weapon.y) + Angles.trnsy(weaponRotation, 0, recoil), - width * Draw.scl * -Mathf.sign(weapon.flipSprite), - weapon.region.getHeight() * Draw.scl, - weaponRotation); - } + Draw.rect(weapon.region, + unit.x + Angles.trnsx(rotation, weapon.x, weapon.y) + Angles.trnsx(weaponRotation, 0, recoil), + unit.y + Angles.trnsy(rotation, weapon.x, weapon.y) + Angles.trnsy(weaponRotation, 0, recoil), + width * Draw.scl * -Mathf.sign(weapon.flipSprite), + weapon.region.getHeight() * Draw.scl, + weaponRotation); } Draw.reset(); diff --git a/core/src/mindustry/type/Weapon.java b/core/src/mindustry/type/Weapon.java index 1dde54513f..c9b5d9f2d1 100644 --- a/core/src/mindustry/type/Weapon.java +++ b/core/src/mindustry/type/Weapon.java @@ -8,6 +8,7 @@ import mindustry.content.*; import mindustry.entities.*; import mindustry.entities.bullet.*; import mindustry.gen.*; +import mindustry.io.*; public class Weapon{ /** displayed weapon region */ @@ -16,12 +17,12 @@ public class Weapon{ public @NonNull BulletType bullet; /** shell ejection effect */ public Effect ejectEffect = Fx.none; - /** whether to mirror the weapon (draw two of them, which is the default) */ + /** whether to create a flipped copy of this weapon upon initialization. default: true */ public boolean mirror = true; - /** whether to flip the weapon's position/side on the ship (only valid when mirror is false) */ - public boolean flipped = false, flipSprite = false; + /** whether to flip the weapon's sprite when rendering */ + public boolean flipSprite = false; /** whether to shoot the weapons in different arms one after another, rather than all at once; only valid when mirror = true */ - public boolean alternate = false; + public boolean alternate = true; /** whether to rotate toward the target independently of unit */ public boolean rotate = false; /** rotation speed of weapon when rotation is enabled, in degrees/t*/ @@ -50,6 +51,8 @@ public class Weapon{ public float shootCone = 5f; /** whether shooter rotation is ignored when shooting. */ public boolean ignoreRotation = false; + /** internal value used for alternation - do not change! */ + public int otherSide = -1; /** sound used for shooting */ public Sound shootSound = Sounds.pew; /** displayed region (autoloaded) */ @@ -63,6 +66,12 @@ public class Weapon{ this(""); } + public Weapon copy(){ + Weapon out = new Weapon(); + JsonIO.json().copyFields(this, out); + return out; + } + public void load(){ region = Core.atlas.find(name, Core.atlas.find("clear")); } diff --git a/core/src/mindustry/world/blocks/defense/TractorBeamTurret.java b/core/src/mindustry/world/blocks/defense/TractorBeamTurret.java index a2d184130c..941393b22d 100644 --- a/core/src/mindustry/world/blocks/defense/TractorBeamTurret.java +++ b/core/src/mindustry/world/blocks/defense/TractorBeamTurret.java @@ -28,6 +28,7 @@ public class TractorBeamTurret extends Block{ public float shootCone = 6f; public float laserWidth = 0.6f; public float force = 0.3f; + public float scaledForce = 0f; public float damage = 0f; public boolean targetAir = true, targetGround = false; @@ -88,7 +89,7 @@ public class TractorBeamTurret extends Block{ //shoot when possible if(Angles.within(rotation, dest, shootCone)){ - target.impulse(Tmp.v1.set(this).sub(target).limit(force * efficiency() * timeScale)); + target.impulse(Tmp.v1.set(this).sub(target).limit((force + (1f - target.dst(this) / range) * scaledForce) * efficiency() * timeScale)); } }else{ target = null; diff --git a/tools/src/mindustry/tools/Generators.java b/tools/src/mindustry/tools/Generators.java index ec8cfe280d..7013910b23 100644 --- a/tools/src/mindustry/tools/Generators.java +++ b/tools/src/mindustry/tools/Generators.java @@ -302,6 +302,7 @@ public class Generators{ if(type.isHidden()) return; //hidden units don't generate type.load(); + type.init(); Image image = ImagePacker.get(type.parts > 0 ? type.partRegions[0] : type.region); for(int i = 1; i < type.parts; i++){ @@ -335,14 +336,10 @@ public class Generators{ for(Weapon weapon : type.weapons){ weapon.load(); - for(int i : (weapon.mirror ? Mathf.signs : Mathf.one)){ - i *= Mathf.sign(weapon.flipped); - - image.draw(weapon.region, - (int)(i * weapon.x / Draw.scl + image.width / 2 - weapon.region.getWidth() / 2), - (int)(-weapon.y / Draw.scl + image.height / 2f - weapon.region.getHeight() / 2f), - i > 0, false); - } + image.draw(weapon.region, + (int)(weapon.x / Draw.scl + image.width / 2f - weapon.region.getWidth() / 2f), + (int)(-weapon.y / Draw.scl + image.height / 2f - weapon.region.getHeight() / 2f), + weapon.flipSprite, false); } image.save("unit-" + type.name + "-full");