Tungsten walls

This commit is contained in:
Anuken
2021-12-13 14:42:16 -05:00
parent 0e99e121e8
commit 5ac3e08b1d
15 changed files with 164 additions and 66 deletions

View File

@@ -510,4 +510,9 @@ public class Damage{
float scaled = Mathf.lerp(1f - dist / radius, 1f, falloff);
return damage * scaled;
}
/** @return resulting armor calculated based off of damage */
public static float applyArmor(float damage, float armor){
return Math.max(damage - armor, minArmorDamage * damage);
}
}

View File

@@ -1549,7 +1549,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
if(Mathf.zero(dm)){
damage = health + 1;
}else{
damage /= dm;
damage = Damage.applyArmor(damage, block.armor) / dm;
}
Call.tileDamage(self(), health - handleDamage(damage));

View File

@@ -3,11 +3,10 @@ package mindustry.entities.comp;
import arc.util.*;
import mindustry.annotations.Annotations.*;
import mindustry.content.*;
import mindustry.entities.*;
import mindustry.game.*;
import mindustry.gen.*;
import static mindustry.Vars.*;
@Component
abstract class ShieldComp implements Healthc, Posc{
@Import float health, hitTime, x, y, healthMultiplier;
@@ -24,11 +23,8 @@ abstract class ShieldComp implements Healthc, Posc{
@Replace
@Override
public void damage(float amount){
//apply armor
amount = Math.max(amount - armor, minArmorDamage * amount);
amount /= healthMultiplier;
rawDamage(amount);
//apply armor and scaling effects
rawDamage(Damage.applyArmor(amount, armor) / healthMultiplier);
}
@Replace

View File

@@ -3,20 +3,24 @@ package mindustry.entities.comp;
import arc.math.*;
import arc.math.geom.*;
import arc.util.*;
import mindustry.*;
import mindustry.annotations.Annotations.*;
import mindustry.content.*;
import mindustry.entities.*;
import mindustry.gen.*;
import mindustry.type.*;
import mindustry.world.*;
import mindustry.world.blocks.environment.*;
import static mindustry.Vars.*;
@Component
abstract class TankComp implements Posc, Flyingc, Hitboxc, Unitc, ElevationMovec{
@Import float x, y, hitSize, rotation;
@Import float x, y, hitSize, rotation, speedMultiplier;
@Import boolean hovering;
@Import UnitType type;
transient private float treadEffectTime;
transient private float treadEffectTime, lastSlowdown = 1f;
transient float treadTime;
transient boolean walked;
@@ -43,6 +47,22 @@ abstract class TankComp implements Posc, Flyingc, Hitboxc, Unitc, ElevationMovec
}
}
//calculate overlapping tiles so it slows down when going "over" walls
//TODO is this a necessary mechanic?
int r = Math.max(Math.round(hitSize * 0.6f / tilesize), 1);
int solids = 0, total = (r*2+1)*(r*2+1);
for(int dx = -r; dx <= r; dx++){
for(int dy = -r; dy <= r; dy++){
Tile t = Vars.world.tileWorld(x + dx*tilesize, y + dy*tilesize);
if(t == null || t.solid()){
solids ++;
}
}
}
lastSlowdown = Mathf.lerp(1f, type.crawlSlowdown, Mathf.clamp((float)solids / total / type.crawlSlowdownFrac));
//trigger animation only when walking manually
if(walked || net.client()){
float len = deltaLen();
@@ -51,6 +71,14 @@ abstract class TankComp implements Posc, Flyingc, Hitboxc, Unitc, ElevationMovec
}
}
@Override
@Replace
public float floorSpeedMultiplier(){
Floor on = isFlying() || hovering ? Blocks.air.asFloor() : floorOn();
//TODO take into account extra blocks
return on.speedMultiplier * speedMultiplier * lastSlowdown;
}
@Replace
@Override
public @Nullable Floor drownFloor(){