diff --git a/core/src/io/anuke/mindustry/entities/Player.java b/core/src/io/anuke/mindustry/entities/Player.java index a8883bb1ff..7df03a2b21 100644 --- a/core/src/io/anuke/mindustry/entities/Player.java +++ b/core/src/io/anuke/mindustry/entities/Player.java @@ -342,7 +342,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra float x = snappedX(), y = snappedY(); Draw.color(Color.BLACK, team.color, healthf() + Mathf.absin(Timers.time(), healthf()*5f, 1f - healthf())); - Draw.alpha(hitTime); + Draw.alpha(hitTime / hitDuration); Draw.rect(getPowerCellRegion(), x, y, rotation - 90); Draw.color(); } @@ -433,7 +433,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra @Override public void update(){ - hitTime = Math.max(0f, hitTime - Timers.delta()); + hitTime -= Timers.delta(); if(Float.isNaN(x) || Float.isNaN(y)){ TileEntity core = getClosestCore(); diff --git a/core/src/io/anuke/mindustry/entities/Unit.java b/core/src/io/anuke/mindustry/entities/Unit.java index 4bd7fc83a3..95761762fa 100644 --- a/core/src/io/anuke/mindustry/entities/Unit.java +++ b/core/src/io/anuke/mindustry/entities/Unit.java @@ -238,7 +238,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ } } - if(onLiquid && velocity.len() > 0.4f && Timers.get(this, "flooreffect", 14 - (velocity.len() * floor.speedMultiplier) * 2f)){ + if(onLiquid && velocity.len() > 0.4f && Mathf.chance((velocity.len() * floor.speedMultiplier) * 0.06f * Timers.delta())){ Effects.effect(floor.walkEffect, floor.liquidColor, x, y); } @@ -250,7 +250,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ if(onLiquid && floor.drownTime > 0){ drownTime += Timers.delta() * 1f / floor.drownTime; - if(Timers.get(this, "drowneffect", 15)){ + if(Mathf.chance(Timers.delta() * 0.05f)){ Effects.effect(floor.drownUpdateEffect, floor.liquidColor, x, y); } }else{ @@ -278,7 +278,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ } public void damagePeriodic(float amount){ - damage(amount * Timers.delta(), Timers.get(this, "damageeffect", 20)); + damage(amount * Timers.delta(), hitTime <= -20 + hitDuration); } public void damage(float amount, boolean withEffect){ diff --git a/core/src/io/anuke/mindustry/entities/bullet/Bullet.java b/core/src/io/anuke/mindustry/entities/bullet/Bullet.java index b406c27e10..c9bc5427a2 100644 --- a/core/src/io/anuke/mindustry/entities/bullet/Bullet.java +++ b/core/src/io/anuke/mindustry/entities/bullet/Bullet.java @@ -30,7 +30,7 @@ public class Bullet extends BulletEntity implements TeamTrait, SyncT public Timer timer = new Timer(3); private Team team; private Object data; - private boolean supressCollision; + private boolean supressCollision, supressOnce, initialized; /**Internal use only!*/ public Bullet(){ @@ -91,8 +91,14 @@ public class Bullet extends BulletEntity implements TeamTrait, SyncT return type.collidesTiles; } - public void supressCollision(){ + public void supress(){ supressCollision = true; + supressOnce = true; + } + + public void absorb(){ + supressCollision = true; + remove(); } public void resetOwner(Entity entity, Team team){ @@ -181,7 +187,7 @@ public class Bullet extends BulletEntity implements TeamTrait, SyncT public void update(){ super.update(); - if(type.hitTiles && collidesTiles() && !supressCollision){ + if(type.hitTiles && collidesTiles() && !supressCollision && !initialized){ world.raycastEach(world.toTile(lastPosition().x), world.toTile(lastPosition().y), world.toTile(x), world.toTile(y), (x, y) -> { Tile tile = world.tile(x, y); @@ -205,7 +211,12 @@ public class Bullet extends BulletEntity implements TeamTrait, SyncT }); } - supressCollision = false; + if(supressOnce){ + supressCollision = false; + supressOnce = false; + } + + initialized = true; } @Override @@ -222,6 +233,7 @@ public class Bullet extends BulletEntity implements TeamTrait, SyncT timer.clear(); team = null; data = null; + initialized = false; } @Override diff --git a/core/src/io/anuke/mindustry/entities/effect/Puddle.java b/core/src/io/anuke/mindustry/entities/effect/Puddle.java index f3b2df91aa..1a78e7a492 100644 --- a/core/src/io/anuke/mindustry/entities/effect/Puddle.java +++ b/core/src/io/anuke/mindustry/entities/effect/Puddle.java @@ -51,6 +51,7 @@ public class Puddle extends BaseEntity implements SaveTrait, Poolable, DrawTrait private int loadedPosition = -1; private float updateTime; + private float lastRipple; private Tile tile; private Liquid liquid; private float amount, targetAmount; @@ -89,9 +90,12 @@ public class Puddle extends BaseEntity implements SaveTrait, Poolable, DrawTrait reactPuddle(tile.floor().liquidDrop, liquid, amount, tile, (tile.worldx() + source.worldx()) / 2f, (tile.worldy() + source.worldy()) / 2f); - if(generation == 0 && Timers.get(tile, "ripple", 50)){ + Puddle p = map.get(tile.packedPosition()); + + if(generation == 0 && p != null && p.lastRipple <= Timers.time() - 40f){ Effects.effect(BlockFx.ripple, tile.floor().liquidDrop.color, (tile.worldx() + source.worldx()) / 2f, (tile.worldy() + source.worldy()) / 2f); + p.lastRipple = Timers.time(); } return; } @@ -111,8 +115,9 @@ public class Puddle extends BaseEntity implements SaveTrait, Poolable, DrawTrait }else if(p.liquid == liquid){ p.accepting = Math.max(amount, p.accepting); - if(generation == 0 && Timers.get(p, "ripple2", 50) && p.amount >= maxLiquid / 2f){ + if(generation == 0 && p.lastRipple <= Timers.time() - 40f && p.amount >= maxLiquid / 2f){ Effects.effect(BlockFx.ripple, p.liquid.color, (tile.worldx() + source.worldx()) / 2f, (tile.worldy() + source.worldy()) / 2f); + p.lastRipple = Timers.time(); } }else{ p.amount -= reactPuddle(p.liquid, liquid, amount, p.tile, p.x, p.y); diff --git a/core/src/io/anuke/mindustry/entities/units/BaseUnit.java b/core/src/io/anuke/mindustry/entities/units/BaseUnit.java index e661ab6590..49c768a474 100644 --- a/core/src/io/anuke/mindustry/entities/units/BaseUnit.java +++ b/core/src/io/anuke/mindustry/entities/units/BaseUnit.java @@ -284,11 +284,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{ @Override public void update(){ - if(hitTime > 0){ - hitTime -= Timers.delta(); - } - - if(hitTime < 0) hitTime = 0; + hitTime -= Timers.delta(); if(isDead()){ updateRespawning(); diff --git a/core/src/io/anuke/mindustry/world/blocks/defense/DeflectorWall.java b/core/src/io/anuke/mindustry/world/blocks/defense/DeflectorWall.java index 7ff42bfe39..946d4499c6 100644 --- a/core/src/io/anuke/mindustry/world/blocks/defense/DeflectorWall.java +++ b/core/src/io/anuke/mindustry/world/blocks/defense/DeflectorWall.java @@ -70,7 +70,7 @@ public class DeflectorWall extends Wall{ bullet.updateVelocity(0f); bullet.resetOwner(entity, Team.none); bullet.scaleTime(1f); - bullet.supressCollision(); + bullet.supress(); ((DeflectorEntity) entity).hit = 1f; } diff --git a/core/src/io/anuke/mindustry/world/blocks/storage/CoreBlock.java b/core/src/io/anuke/mindustry/world/blocks/storage/CoreBlock.java index ed2a6547a4..86b1bba1ab 100644 --- a/core/src/io/anuke/mindustry/world/blocks/storage/CoreBlock.java +++ b/core/src/io/anuke/mindustry/world/blocks/storage/CoreBlock.java @@ -187,8 +187,7 @@ public class CoreBlock extends StorageBlock{ if(bullet.getOwner() instanceof Player && bullet.getTeam() != tile.getTeam()){ Effects.effect(BulletFx.absorb, bullet); entity.shieldHeat = 1f; - bullet.supressCollision(); - bullet.remove(); + bullet.absorb(); } });