From 62a3f307559636afec6e2559b6f0d87cf3f647ae Mon Sep 17 00:00:00 2001 From: Rex Aliis <77251557+RexAliis@users.noreply.github.com> Date: Sun, 21 Aug 2022 11:31:41 -0300 Subject: [PATCH 1/5] Update contributors (#7406) --- core/assets/contributors | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/assets/contributors b/core/assets/contributors index e66b9c2ce4..a6536f4f0a 100644 --- a/core/assets/contributors +++ b/core/assets/contributors @@ -41,7 +41,7 @@ Jan Polák JrTRinny JustYanns BasedUser -RexHm +Rex Aliis BLucky-gh DinoWattz Jae @@ -147,4 +147,4 @@ KayAyeAre SMOLKEYS 1stvaliduser(SUS) GlennFolker -BlackDeluxeCat \ No newline at end of file +BlackDeluxeCat From dde9f895cf7423767efdd908640a20637ad7d80f Mon Sep 17 00:00:00 2001 From: zenonet <78077158+zenonet@users.noreply.github.com> Date: Sun, 21 Aug 2022 16:32:58 +0200 Subject: [PATCH 2/5] Added `autoPause` config for servers (#7405) * Extracted the method ServerControl.setPauseState() * Added a comment to EventType.PlayerLeave * Added the `pauseWithoutPlayers` config * Revert "Extracted the method ServerControl.setPauseState()" This reverts commit 45f5b01547c0e745c12a9623834ab9d2a2fbdd10. * Renamed pauseWithoutPlayers to autoPause, fixed manual- and automatic pausing to interfere and made the server pause when hosting a new game * Added a dot to the config description of `autoPause` and added my name to the contributors list * Refactoring * Merged remote-tracking changed I guess * More refactoring * More refactoring * Removed logging about autoPause * Removed another log I forgot in the last commit Co-authored-by: Anuken --- core/assets/contributors | 1 + core/src/mindustry/game/EventType.java | 1 + core/src/mindustry/net/Administration.java | 3 ++- .../src/mindustry/server/ServerControl.java | 24 +++++++++++++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/core/assets/contributors b/core/assets/contributors index a6536f4f0a..61f5ef7943 100644 --- a/core/assets/contributors +++ b/core/assets/contributors @@ -148,3 +148,4 @@ SMOLKEYS 1stvaliduser(SUS) GlennFolker BlackDeluxeCat +zenonet diff --git a/core/src/mindustry/game/EventType.java b/core/src/mindustry/game/EventType.java index 6efcc19e04..faaad3d6be 100644 --- a/core/src/mindustry/game/EventType.java +++ b/core/src/mindustry/game/EventType.java @@ -554,6 +554,7 @@ public class EventType{ } } + /** Called before a player leaves the game. */ public static class PlayerLeave{ public final Player player; diff --git a/core/src/mindustry/net/Administration.java b/core/src/mindustry/net/Administration.java index 7982dce937..e6ed620551 100644 --- a/core/src/mindustry/net/Administration.java +++ b/core/src/mindustry/net/Administration.java @@ -487,7 +487,8 @@ public class Administration{ autosaveAmount = new Config("autosaveAmount", "The maximum amount of autosaves. Older ones get replaced.", 10), autosaveSpacing = new Config("autosaveSpacing", "Spacing between autosaves in seconds.", 60 * 5), debug = new Config("debug", "Enable debug logging", false, () -> Log.level = debug() ? LogLevel.debug : LogLevel.info), - snapshotInterval = new Config("snapshotInterval", "Client entity snapshot interval in ms.", 200); + snapshotInterval = new Config("snapshotInterval", "Client entity snapshot interval in ms.", 200), + autoPause = new Config("autoPause", "Whether the game should pause when nobody is online.", false); public final Object defaultValue; public final String name, key, description; diff --git a/server/src/mindustry/server/ServerControl.java b/server/src/mindustry/server/ServerControl.java index 6efe7f7ede..5440f775e1 100644 --- a/server/src/mindustry/server/ServerControl.java +++ b/server/src/mindustry/server/ServerControl.java @@ -64,6 +64,7 @@ public class ServerControl implements ApplicationListener{ private ServerSocket serverSocket; private PrintWriter socketOutput; private String suggested; + private boolean autoPaused = false; public ServerControl(String[] args){ setup(args); @@ -269,6 +270,23 @@ public class ServerControl implements ApplicationListener{ info("Server loaded. Type @ for help.", "'help'"); }); + + Events.on(PlayerJoin.class, e -> { + if(state.serverPaused && autoPaused && Config.autoPause.bool()){ + state.serverPaused = false; + autoPaused = false; + } + }); + + Events.on(PlayerLeave.class, e -> { + // The player list length is compared with 1 and not 0 here, + // because when PlayerLeave gets fired, the player hasn't been removed from the player list yet + if(!state.serverPaused && Config.autoPause.bool() && Groups.player.size() == 1){ + state.serverPaused = true; + autoPaused = true; + } + }); + } protected void registerCommands(){ @@ -352,6 +370,11 @@ public class ServerControl implements ApplicationListener{ info("Map loaded."); netServer.openServer(); + + if(Config.autoPause.bool()){ + state.serverPaused = true; + autoPaused = true; + } }catch(MapException e){ err(e.map.name() + ": " + e.getMessage()); } @@ -467,6 +490,7 @@ public class ServerControl implements ApplicationListener{ handler.register("pause", "", "Pause or unpause the game.", arg -> { boolean pause = arg[0].equals("on"); + autoPaused = false; state.serverPaused = pause; info(pause ? "Game paused." : "Game unpaused."); }); From 11e3f85242de597c03b3c969026f960b409506ff Mon Sep 17 00:00:00 2001 From: MEEPofFaith <54301439+MEEPofFaith@users.noreply.github.com> Date: Sun, 21 Aug 2022 14:09:47 -0700 Subject: [PATCH 3/5] Fix more things that hit non-hittable units (#7408) * hittable check for EMP * hittable check for Damage#status * why push if don't get hit --- core/src/mindustry/entities/Damage.java | 2 +- core/src/mindustry/entities/bullet/EmpBulletType.java | 2 +- core/src/mindustry/entities/comp/UnitComp.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/mindustry/entities/Damage.java b/core/src/mindustry/entities/Damage.java index 563d9048b8..705b9d26c7 100644 --- a/core/src/mindustry/entities/Damage.java +++ b/core/src/mindustry/entities/Damage.java @@ -440,7 +440,7 @@ public class Damage{ /** Applies a status effect to all enemy units in a range. */ public static void status(Team team, float x, float y, float radius, StatusEffect effect, float duration, boolean air, boolean ground){ Cons cons = entity -> { - if(entity.team == team || !entity.within(x, y, radius) || (entity.isFlying() && !air) || (entity.isGrounded() && !ground)){ + if(entity.team == team || !entity.checkTarget(air, ground) || !entity.hittable() || !entity.within(x, y, radius)){ return; } diff --git a/core/src/mindustry/entities/bullet/EmpBulletType.java b/core/src/mindustry/entities/bullet/EmpBulletType.java index 8f793c4e50..6306d81b7a 100644 --- a/core/src/mindustry/entities/bullet/EmpBulletType.java +++ b/core/src/mindustry/entities/bullet/EmpBulletType.java @@ -48,7 +48,7 @@ public class EmpBulletType extends BasicBulletType{ if(hitUnits){ Units.nearbyEnemies(b.team, x, y, radius, other -> { - if(other.team != b.team){ + if(other.team != b.team && other.hittable()){ var absorber = Damage.findAbsorber(b.team, x, y, other.x, other.y); if(absorber != null){ return; diff --git a/core/src/mindustry/entities/comp/UnitComp.java b/core/src/mindustry/entities/comp/UnitComp.java index 43fa80e2c7..0009e06ca7 100644 --- a/core/src/mindustry/entities/comp/UnitComp.java +++ b/core/src/mindustry/entities/comp/UnitComp.java @@ -470,7 +470,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I drag = type.drag * (isGrounded() ? (floorOn().dragMultiplier) : 1f) * dragMultiplier * state.rules.dragMultiplier; //apply knockback based on spawns - if(team != state.rules.waveTeam && state.hasSpawns() && (!net.client() || isLocal())){ + if(team != state.rules.waveTeam && state.hasSpawns() && (!net.client() || isLocal()) && hittable()){ float relativeSize = state.rules.dropZoneRadius + hitSize/2f + 1f; for(Tile spawn : spawner.getSpawns()){ if(within(spawn.worldx(), spawn.worldy(), relativeSize)){ From 1c3538321b2583ec899a35a1e0bcf35536e7d97e Mon Sep 17 00:00:00 2001 From: MEEPofFaith <54301439+MEEPofFaith@users.noreply.github.com> Date: Sun, 21 Aug 2022 14:10:39 -0700 Subject: [PATCH 4/5] acceptsPayload = true (PayloadAmmoTurret) (#7409) --- .../world/blocks/defense/turrets/PayloadAmmoTurret.java | 1 + 1 file changed, 1 insertion(+) diff --git a/core/src/mindustry/world/blocks/defense/turrets/PayloadAmmoTurret.java b/core/src/mindustry/world/blocks/defense/turrets/PayloadAmmoTurret.java index 2da5ae500e..93308b8b0e 100644 --- a/core/src/mindustry/world/blocks/defense/turrets/PayloadAmmoTurret.java +++ b/core/src/mindustry/world/blocks/defense/turrets/PayloadAmmoTurret.java @@ -26,6 +26,7 @@ public class PayloadAmmoTurret extends Turret{ super(name); maxAmmo = 3; + acceptsPayload = true; } /** Initializes accepted ammo map. Format: [block1, bullet1, block2, bullet2...] */ From 9811aa03ecabd43c602d84a242d5bc6c38a60ae6 Mon Sep 17 00:00:00 2001 From: MEEPofFaith <54301439+MEEPofFaith@users.noreply.github.com> Date: Sun, 21 Aug 2022 14:11:13 -0700 Subject: [PATCH 5/5] Stay warmed up while charging (#7410) * Stay warmed up while charging * Same with unit weapons also add lenearWarmup --- core/src/mindustry/type/Weapon.java | 10 +++++++++- .../mindustry/world/blocks/defense/turrets/Turret.java | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/core/src/mindustry/type/Weapon.java b/core/src/mindustry/type/Weapon.java index 50e9e2b017..d4b2517b57 100644 --- a/core/src/mindustry/type/Weapon.java +++ b/core/src/mindustry/type/Weapon.java @@ -93,6 +93,8 @@ public class Weapon implements Cloneable{ public float minWarmup = 0f; /** lerp speed for shoot warmup, only used for parts */ public float shootWarmupSpeed = 0.1f, smoothReloadSpeed = 0.15f; + /** If true, shoot warmup is linear instead of a curve. */ + public boolean linearWarmup = false; /** random sound pitch range */ public float soundPitchMin = 0.8f, soundPitchMax = 1f; /** whether shooter rotation is ignored when shooting. */ @@ -253,9 +255,15 @@ public class Weapon implements Cloneable{ float lastReload = mount.reload; mount.reload = Math.max(mount.reload - Time.delta * unit.reloadMultiplier, 0); mount.recoil = Mathf.approachDelta(mount.recoil, 0, unit.reloadMultiplier / recoilTime); - mount.warmup = Mathf.lerpDelta(mount.warmup, (can && mount.shoot) || (continuous && mount.bullet != null) ? 1f : 0f, shootWarmupSpeed); mount.smoothReload = Mathf.lerpDelta(mount.smoothReload, mount.reload / reload, smoothReloadSpeed); mount.charge = mount.charging && shoot.firstShotDelay > 0 ? Mathf.approachDelta(mount.charge, 1, 1 / shoot.firstShotDelay) : 0; + + float warmupTarget = (can && mount.shoot) || (continuous && mount.bullet != null) || mount.charging ? 1f : 0f; + if(linearWarmup){ + mount.warmup = Mathf.approachDelta(mount.warmup, warmupTarget, shootWarmupSpeed); + }else{ + mount.warmup = Mathf.lerpDelta(mount.warmup, warmupTarget, shootWarmupSpeed); + } //rotate if applicable if(rotate && (mount.rotate || mount.shoot) && can){ diff --git a/core/src/mindustry/world/blocks/defense/turrets/Turret.java b/core/src/mindustry/world/blocks/defense/turrets/Turret.java index 49d0766ce5..8485b89c4c 100644 --- a/core/src/mindustry/world/blocks/defense/turrets/Turret.java +++ b/core/src/mindustry/world/blocks/defense/turrets/Turret.java @@ -343,7 +343,7 @@ public class Turret extends ReloadTurret{ public void updateTile(){ if(!validateTarget()) target = null; - float warmupTarget = isShooting() && canConsume() ? 1f : 0f; + float warmupTarget = (isShooting() && canConsume()) || charging() ? 1f : 0f; if(linearWarmup){ shootWarmup = Mathf.approachDelta(shootWarmup, warmupTarget, shootWarmupSpeed * (warmupTarget > 0 ? efficiency : 1f)); }else{