From 5e324e71d43b04f0c066b328aa25a363e66ad3e6 Mon Sep 17 00:00:00 2001 From: MEEPofFaith <54301439+MEEPofFaith@users.noreply.github.com> Date: Sat, 14 Jan 2023 07:05:30 -0800 Subject: [PATCH 1/3] Hitscan fix 2 (#8175) * Revert "Reverting #8037" Re-implement #8037 * Properly count collisions Fix #8170 --- core/src/mindustry/entities/Damage.java | 118 ++++++++++++++---------- 1 file changed, 67 insertions(+), 51 deletions(-) diff --git a/core/src/mindustry/entities/Damage.java b/core/src/mindustry/entities/Damage.java index 04b87492fb..e7323d395b 100644 --- a/core/src/mindustry/entities/Damage.java +++ b/core/src/mindustry/entities/Damage.java @@ -6,6 +6,7 @@ import arc.math.*; import arc.math.geom.*; import arc.struct.*; import arc.util.*; +import arc.util.pooling.*; import mindustry.content.*; import mindustry.core.*; import mindustry.game.EventType.*; @@ -26,6 +27,8 @@ public class Damage{ private static final Seq units = new Seq<>(); private static final IntSet collidedBlocks = new IntSet(); private static final IntFloatMap damages = new IntFloatMap(); + private static final Seq collided = new Seq<>(); + private static final Pool collidePool = Pools.get(Collided.class, Collided::new); private static final Seq builds = new Seq<>(); private static final FloatSeq distances = new FloatSeq(); @@ -184,7 +187,7 @@ public class Damage{ return Math.min(distances.size < pierceCap || pierceCap < 0 ? length : Math.max(6f, distances.get(pierceCap - 1)), maxDst); } - /** TODO Collides a bullet with blocks in a laser, taking into account absorption blocks. Resulting length is stored in the bullet's fdata. */ + /** Collides a bullet with blocks in a laser, taking into account absorption blocks. Resulting length is stored in the bullet's fdata. */ public static float collideLaser(Bullet b, float length, boolean large, boolean laser, int pierceCap){ float resultLength = findPierceLength(b, pierceCap, length); @@ -226,40 +229,27 @@ public class Damage{ length = findPierceLength(hitter, pierceCap, length); } - //TODO pierceCount ++ should happen in blocks AND units! - collidedBlocks.clear(); vec.trnsExact(angle, length); - Intc2 collider = (cx, cy) -> { - Building tile = world.build(cx, cy); - boolean collide = tile != null && hitter.checkUnderBuild(tile, cx * tilesize, cy * tilesize) && collidedBlocks.add(tile.pos()); - - if(hitter.damage > 0){ - float health = !collide ? 0 : tile.health; - - if(collide && tile.team != team && tile.collide(hitter)){ - tile.collision(hitter); - hitter.type.hit(hitter, cx * tilesize, cy * tilesize); - } - - //try to heal the tile - if(collide && hitter.type.testCollision(hitter, tile)){ - hitter.type.hitTile(hitter, tile, cx * tilesize, cy * tilesize, health, false); - } - } - }; - if(hitter.type.collidesGround){ seg1.set(x, y); seg2.set(seg1).add(vec); World.raycastEachWorld(x, y, seg2.x, seg2.y, (cx, cy) -> { - collider.get(cx, cy); + Building tile = world.build(cx, cy); + boolean collide = tile != null && hitter.checkUnderBuild(tile, cx * tilesize, cy * tilesize) + && ((tile.team != team && tile.collide(hitter)) || hitter.type.testCollision(hitter, tile)) && collidedBlocks.add(tile.pos()); + if(collide){ + collided.add(collidePool.obtain().set(cx * tilesize, cy * tilesize, tile)); - for(Point2 p : Geometry.d4){ - Tile other = world.tile(p.x + cx, p.y + cy); - if(other != null && (large || Intersector.intersectSegmentRectangle(seg1, seg2, other.getBounds(Tmp.r1)))){ - collider.get(cx + p.x, cy + p.y); + for(Point2 p : Geometry.d4){ + Tile other = world.tile(p.x + cx, p.y + cy); + if(other != null && (large || Intersector.intersectSegmentRectangle(seg1, seg2, other.getBounds(Tmp.r1)))){ + Building build = other.build; + if(build != null && hitter.checkUnderBuild(build, cx * tilesize, cy * tilesize) && collidedBlocks.add(build.pos())){ + collided.add(collidePool.obtain().set((p.x + cx * tilesize), (p.y + cy) * tilesize, build)); + } + } } } return false; @@ -271,32 +261,46 @@ public class Damage{ rect.setPosition(x, y).setSize(vec.x, vec.y).normalize().grow(expand * 2f); float x2 = vec.x + x, y2 = vec.y + y; - Cons cons = e -> { - if(!e.hittable()) return; - //the peirce cap works for units, but really terribly, I'm just disabling it for now. - //if(pierceCap > 0 && pierceCount > pierceCap) return; - - e.hitbox(hitrect); - - Vec2 vec = Geometry.raycastRect(x, y, x2, y2, hitrect.grow(expand * 2)); - - if(vec != null && hitter.damage > 0){ - effect.at(vec.x, vec.y); - e.collision(hitter, vec.x, vec.y); - hitter.collision(e, vec.x, vec.y); - } - }; - - units.clear(); - Units.nearbyEnemies(team, rect, u -> { - if(u.checkTarget(hitter.type.collidesAir, hitter.type.collidesGround)){ - units.add(u); + if(u.checkTarget(hitter.type.collidesAir, hitter.type.collidesGround) && u.hittable()){ + u.hitbox(hitrect); + + Vec2 vec = Geometry.raycastRect(x, y, x2, y2, hitrect.grow(expand * 2)); + + if(vec != null){ + collided.add(collidePool.obtain().set(vec.x, vec.y, u)); + } } }); - units.sort(u -> u.dst2(hitter)); - units.each(cons); + int[] collideCount = {0}; + collided.sort(c -> hitter.dst2(c.x, c.y)); + collided.each(c -> { + if(hitter.damage > 0 && (pierceCap <= 0 || collideCount[0] < pierceCap)){ + if(c.target instanceof Unit u){ + effect.at(c.x, c.y); + u.collision(hitter, c.x, c.y); + hitter.collision(u, c.x, c.y); + collideCount[0]++; + }else if(c.target instanceof Building tile){ + float health = tile.health; + + if(tile.team != team && tile.collide(hitter)){ + tile.collision(hitter); + hitter.type.hit(hitter, c.x, c.y); + collideCount[0]++; + } + + //try to heal the tile + if(hitter.type.testCollision(hitter, tile)){ + hitter.type.hitTile(hitter, tile, c.x, c.y, health, false); + } + } + } + }); + + collidePool.freeAll(collided); + collided.clear(); } /** @@ -338,7 +342,7 @@ public class Damage{ */ public static Healthc linecast(Bullet hitter, float x, float y, float angle, float length){ vec.trns(angle, length); - + tmpBuilding = null; if(hitter.type.collidesGround){ @@ -613,4 +617,16 @@ public class Damage{ public static float applyArmor(float damage, float armor){ return Math.max(damage - armor, minArmorDamage * damage); } -} \ No newline at end of file + + public static class Collided{ + public float x, y; + public Teamc target; + + public Collided set(float x, float y, Teamc target){ + this.x = x; + this.y = y; + this.target = target; + return this; + } + } +} From 98157f28523ecbd903fb8f57cd6303ff81f96181 Mon Sep 17 00:00:00 2001 From: Knochi Date: Sat, 14 Jan 2023 20:41:14 +0100 Subject: [PATCH 2/3] =?UTF-8?q?Never=20use=20=E2=80=9Etun=E2=80=9C=20in=20?= =?UTF-8?q?German=20language=20(#8179)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/assets/bundles/bundle_de.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/assets/bundles/bundle_de.properties b/core/assets/bundles/bundle_de.properties index e3c8899b3c..7904879f5a 100644 --- a/core/assets/bundles/bundle_de.properties +++ b/core/assets/bundles/bundle_de.properties @@ -1759,7 +1759,7 @@ hint.skip = Fertig hint.desktopMove = Drücke [accent][[WASD][], um dich zu bewegen. hint.zoom = [accent]Scrolle[], um rein oder raus zu zoomen. hint.desktopShoot = Benutze [accent][[Linksklick][], um zu schießen. -hint.depositItems = Um Materialien in den Kern zu tun, ziehe sie von dir zum Kern. +hint.depositItems = Um Materialien in den Kern zu verschieben, ziehe sie von dir zum Kern. hint.respawn = Um im Kern zu respawnen, drücke [accent][[V][]. hint.respawn.mobile = Du steuerst nun eine Einheit oder einen Block. Um wieder zur normalen Einheit zu werden, [accent]drücke die Abbildung von dir oben links[]. hint.desktopPause = Benutze [accent][[Leertaste][], um das Spiel zu pausieren oder entpausieren. From 597bd31a0c7e6817f29c2f2455fb4d8b3d9ab461 Mon Sep 17 00:00:00 2001 From: DinnerWool <121786868+DinnerWool@users.noreply.github.com> Date: Sun, 15 Jan 2023 20:42:59 +0700 Subject: [PATCH 3/3] Update servers_v7.json (#8183) --- servers_v7.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/servers_v7.json b/servers_v7.json index e946b2832b..41f184d34c 100644 --- a/servers_v7.json +++ b/servers_v7.json @@ -142,5 +142,9 @@ { "name": "SubZero", "address": ["mintyserver.net"] + }, + { + "name": "Vndustry", + "address": ["vndustry.ddns.net","vndustry.ddns.net:6568"] } ]