This commit is contained in:
Anuken
2020-06-07 17:22:17 -04:00
parent 6c00b2a0ff
commit 210971fedb
19 changed files with 839 additions and 784 deletions

View File

@@ -13,6 +13,7 @@ import mindustry.game.EventType.*;
import mindustry.game.*;
import mindustry.gen.*;
import mindustry.graphics.*;
import mindustry.type.*;
import mindustry.world.*;
import static mindustry.Vars.*;
@@ -173,9 +174,37 @@ public class Damage{
}
/** Damages all entities and blocks in a radius that are enemies of the team. */
public static void damage(Team team, float x, float y, float radius, float damage, boolean complete){
public static void damage(Team team, float x, float y, float radius, float damage, boolean air, boolean ground){
damage(team, x, y, radius, damage, false, air, ground);
}
/** 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<Unitc> cons = entity -> {
if(entity.team() == team || entity.dst(x, y) > radius){
if(entity.team() == team || !entity.within(x, y, radius) || (entity.isFlying() && !air) || (entity.isGrounded() && !ground)){
return;
}
entity.apply(effect, duration);
};
rect.setSize(radius * 2).setCenter(x, y);
if(team != null){
Units.nearbyEnemies(team, rect, cons);
}else{
Units.nearby(rect, cons);
}
}
/** Damages all entities and blocks in a radius that are enemies of the team. */
public static void damage(Team team, float x, float y, float radius, float damage, boolean complete){
damage(team, x, y, radius, damage, complete, true, true);
}
/** Damages all entities and blocks in a radius that are enemies of the team. */
public static void damage(Team team, float x, float y, float radius, float damage, boolean complete, boolean air, boolean ground){
Cons<Unitc> cons = entity -> {
if(entity.team() == team || !entity.within(x, y, radius) || (entity.isFlying() && !air) || (entity.isGrounded() && !ground)){
return;
}
float amount = calculateDamage(x, y, entity.getX(), entity.getY(), radius, damage);

View File

@@ -48,8 +48,6 @@ public abstract class BulletType extends Content{
public float splashDamage = 0f;
/** Knockback in velocity. */
public float knockback;
/** Whether this bullet hits tiles. */
public boolean hitTiles = true;
/** Status effect applied on hit. */
public StatusEffect status = StatusEffects.none;
/** Intensity of applied status effect in terms of duration. */
@@ -139,7 +137,11 @@ public abstract class BulletType extends Content{
}
if(splashDamageRadius > 0){
Damage.damage(b.team(), x, y, splashDamageRadius, splashDamage * b.damageMultiplier());
Damage.damage(b.team(), x, y, splashDamageRadius, splashDamage * b.damageMultiplier(), collidesAir, collidesGround);
if(status != StatusEffects.none){
Damage.status(b.team(), x, y, splashDamageRadius, status, statusDuration, collidesAir, collidesGround);
}
}
for(int i = 0; i < lightning; i++){

View File

@@ -53,7 +53,7 @@ public class LaserBulletType extends BulletType{
furthest = null;
world.raycast(b.tileX(), b.tileY(), world.toTile(b.x() + Tmp.v1.x), world.toTile(b.y() + Tmp.v1.y),
(x, y) -> (furthest = world.tile(x, y)) != null && furthest.block().absorbLasers);
(x, y) -> (furthest = world.tile(x, y)) != null && furthest.team() != b.team() && furthest.block().absorbLasers);
float resultLength = furthest != null ? Math.max(6f, b.dst(furthest.worldx(), furthest.worldy())) : length;

View File

@@ -107,7 +107,7 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw
public void update(){
type.update(this);
if(type.hitTiles){
if(type.collidesTiles){
world.raycastEach(world.toTile(lastX()), world.toTile(lastY()), tileX(), tileY(), (x, y) -> {
Tilec tile = world.ent(x, y);