diff --git a/core/src/io/anuke/mindustry/content/UnitTypes.java b/core/src/io/anuke/mindustry/content/UnitTypes.java index 33b4a7cacf..16f630433c 100644 --- a/core/src/io/anuke/mindustry/content/UnitTypes.java +++ b/core/src/io/anuke/mindustry/content/UnitTypes.java @@ -37,6 +37,7 @@ public class UnitTypes implements ContentList{ }; spirit = new UnitType("spirit", Spirit.class, Spirit::new){{ + weapon = Weapons.healBlasterDrone; isFlying = true; drag = 0.01f; speed = 0.2f; diff --git a/core/src/io/anuke/mindustry/content/Weapons.java b/core/src/io/anuke/mindustry/content/Weapons.java index f37796ba13..6875f4d392 100644 --- a/core/src/io/anuke/mindustry/content/Weapons.java +++ b/core/src/io/anuke/mindustry/content/Weapons.java @@ -7,7 +7,7 @@ import io.anuke.mindustry.type.ContentType; import io.anuke.mindustry.type.Weapon; public class Weapons implements ContentList{ - public static Weapon blaster, blasterSmall, glaiveBlaster, droneBlaster, healBlaster, chainBlaster, shockgun, + public static Weapon blaster, blasterSmall, glaiveBlaster, droneBlaster, healBlaster, healBlasterDrone, chainBlaster, shockgun, sapper, swarmer, bomber, bomberTrident, flakgun, flamethrower, missiles, artillery, laserBurster; @Override @@ -169,6 +169,16 @@ public class Weapons implements ContentList{ ejectEffect = Fx.none; ammo = AmmoTypes.lancerLaser; }}; + + healBlasterDrone = new Weapon("heal-blaster"){{ + length = 1.5f; + reload = 40f; + width = 0.5f; + roundrobin = true; + ejectEffect = Fx.none; + recoil = 2f; + ammo = AmmoTypes.healBlaster; + }}; } @Override diff --git a/core/src/io/anuke/mindustry/content/bullets/TurretBullets.java b/core/src/io/anuke/mindustry/content/bullets/TurretBullets.java index addcb75960..2b28ec0016 100644 --- a/core/src/io/anuke/mindustry/content/bullets/TurretBullets.java +++ b/core/src/io/anuke/mindustry/content/bullets/TurretBullets.java @@ -43,7 +43,7 @@ public class TurretBullets extends BulletList implements ContentList{ }; healBullet = new BulletType(5.2f, 13){ - float healAmount = 21f; + float healPercent = 3f; { hiteffect = BulletFx.hitLaser; @@ -51,6 +51,11 @@ public class TurretBullets extends BulletList implements ContentList{ collidesTeam = true; } + @Override + public boolean collides(Bullet b, Tile tile){ + return tile.getTeam() != b.getTeam() || tile.entity.healthf() < 1f; + } + @Override public void draw(Bullet b){ Draw.color(Palette.heal); @@ -67,8 +72,8 @@ public class TurretBullets extends BulletList implements ContentList{ tile = tile.target(); if(tile.getTeam() == b.getTeam() && !(tile.block() instanceof BuildBlock)){ - Effects.effect(BlockFx.healBlock, tile.drawx(), tile.drawy(), tile.block().size); - tile.entity.healBy(healAmount); + Effects.effect(BlockFx.healBlockFull, Palette.heal, tile.drawx(), tile.drawy(), tile.block().size); + tile.entity.healBy(healPercent / 100f * tile.entity.maxHealth()); } } }; diff --git a/core/src/io/anuke/mindustry/entities/bullet/Bullet.java b/core/src/io/anuke/mindustry/entities/bullet/Bullet.java index f3d60b86f6..f918d6ce8b 100644 --- a/core/src/io/anuke/mindustry/entities/bullet/Bullet.java +++ b/core/src/io/anuke/mindustry/entities/bullet/Bullet.java @@ -209,7 +209,7 @@ public class Bullet extends BulletEntity implements TeamTrait, SyncT if(tile == null) return false; tile = tile.target(); - if(tile.entity != null && tile.entity.collide(this) && !tile.entity.isDead() && (type.collidesTeam || tile.getTeam() != team)){ + if(tile.entity != null && tile.entity.collide(this) && type.collides(this, tile) && !tile.entity.isDead() && (type.collidesTeam || tile.getTeam() != team)){ if(tile.getTeam() != team){ tile.entity.collision(this); } diff --git a/core/src/io/anuke/mindustry/entities/bullet/BulletType.java b/core/src/io/anuke/mindustry/entities/bullet/BulletType.java index 916ebbb52c..b6220dd9dd 100644 --- a/core/src/io/anuke/mindustry/entities/bullet/BulletType.java +++ b/core/src/io/anuke/mindustry/entities/bullet/BulletType.java @@ -55,6 +55,10 @@ public abstract class BulletType extends Content implements BaseBulletType type.range){ circle(type.range*0.9f); }else{ - TileEntity entity = (TileEntity) target; - entity.healBy(type.healSpeed * entity.tile.block().health / 100f * Timers.delta()); - - if(timer.get(timerRepairEffect, 30)){ - Effects.effect(BlockFx.healBlockFull, Palette.heal, entity.x, entity.y, entity.tile.block().size); - } + getWeapon().update(Drone.this, target.getX(), target.getY()); } } }, @@ -317,16 +306,6 @@ public class Drone extends FlyingUnit implements BuilderTrait{ target = null; } - if(Net.client() && state.is(repair) && target instanceof TileEntity && target.distanceTo(this) < type.range){ - TileEntity entity = (TileEntity) target; - entity.health += type.healSpeed * Timers.delta(); - entity.health = Mathf.clamp(entity.health, 0, entity.tile.block().health); - - if(timer.get(timerRepairEffect, 30)){ - Effects.effect(BlockFx.healBlockFull, Palette.heal, entity.x, entity.y, entity.tile.block().size); - } - } - updateBuilding(this); } @@ -355,19 +334,6 @@ public class Drone extends FlyingUnit implements BuilderTrait{ @Override public void drawOver(){ trail.draw(Palette.lightTrail, 3f); - - TargetTrait entity = target; - - if(entity instanceof TileEntity && state.is(repair) && target.distanceTo(this) < type.range){ - float len = 5f; - Draw.color(Color.BLACK, Color.WHITE, 0.95f + Mathf.absin(Timers.time(), 0.8f, 0.05f)); - Shapes.laser("beam", "beam-end", - x + Angles.trnsx(rotation, len), - y + Angles.trnsy(rotation, len), - entity.getX(), entity.getY()); - Draw.color(); - } - drawBuilding(this); } diff --git a/core/src/io/anuke/mindustry/world/blocks/defense/MendingWall.java b/core/src/io/anuke/mindustry/world/blocks/defense/MendingWall.java deleted file mode 100644 index aabcbcd8ef..0000000000 --- a/core/src/io/anuke/mindustry/world/blocks/defense/MendingWall.java +++ /dev/null @@ -1,58 +0,0 @@ -package io.anuke.mindustry.world.blocks.defense; - -import com.badlogic.gdx.graphics.Color; -import io.anuke.mindustry.entities.TileEntity; -import io.anuke.mindustry.entities.bullet.Bullet; -import io.anuke.mindustry.world.Tile; -import io.anuke.mindustry.world.blocks.defense.DeflectorWall.DeflectorEntity; -import io.anuke.ucore.core.Graphics; -import io.anuke.ucore.core.Timers; -import io.anuke.ucore.graphics.Draw; -import io.anuke.ucore.util.Mathf; - -import static io.anuke.mindustry.Vars.tilesize; - -public class MendingWall extends Wall{ - protected float regenSpeed = 0.25f; - - public MendingWall(String name){ - super(name); - update = true; - } - - @Override - public void handleBulletHit(TileEntity entity, Bullet bullet){ - super.handleBulletHit(entity, bullet); - ((DeflectorEntity) entity).hit = 1f; - } - - @Override - public void draw(Tile tile){ - super.draw(tile); - - DeflectorEntity entity = tile.entity(); - - if(entity.hit < 0.0001f) return; - - Graphics.setAdditiveBlending(); - - Draw.color(Color.WHITE); - Draw.alpha(entity.hit * 0.5f); - Draw.rect("blank", tile.drawx(), tile.drawy(), tilesize * size, tilesize * size); - Draw.reset(); - - entity.hit = Mathf.clamp(entity.hit - Timers.delta() / DeflectorWall.hitTime); - - Graphics.setNormalBlending(); - } - - @Override - public void update(Tile tile){ - tile.entity.health = Mathf.clamp(tile.entity.health + regenSpeed * Timers.delta(), 0f, health); - } - - @Override - public TileEntity newEntity(){ - return new DeflectorEntity(); - } -}