Cleanup / Armor support

This commit is contained in:
Anuken
2020-05-21 14:57:15 -04:00
parent b562c30381
commit 61d9fd3d72
31 changed files with 481 additions and 455 deletions

View File

@ -0,0 +1 @@
{version:1,fields:[{name:armor,type:float,size:4},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:requests,type:arc.struct.Queue<mindustry.entities.units.BuildRequest>,size:-1},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:stack,type:mindustry.type.ItemStack,size:-1},{name:statuses,type:arc.struct.Array<mindustry.entities.units.StatusEntry>,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:vel,type:arc.math.geom.Vec2,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]}

View File

@ -0,0 +1 @@
{version:1,fields:[{name:armor,type:float,size:4},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:stack,type:mindustry.type.ItemStack,size:-1},{name:statuses,type:arc.struct.Array<mindustry.entities.units.StatusEntry>,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:vel,type:arc.math.geom.Vec2,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]}

View File

@ -0,0 +1 @@
{version:1,fields:[{name:armor,type:float,size:4},{name:baseRotation,type:float,size:4},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:stack,type:mindustry.type.ItemStack,size:-1},{name:statuses,type:arc.struct.Array<mindustry.entities.units.StatusEntry>,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:vel,type:arc.math.geom.Vec2,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]}

View File

@ -0,0 +1 @@
{version:1,fields:[{name:armor,type:float,size:4},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:mineTile,type:mindustry.world.Tile,size:-1},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:stack,type:mindustry.type.ItemStack,size:-1},{name:statuses,type:arc.struct.Array<mindustry.entities.units.StatusEntry>,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:vel,type:arc.math.geom.Vec2,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]}

View File

@ -0,0 +1 @@
{version:1,fields:[{name:armor,type:float,size:4},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:stack,type:mindustry.type.ItemStack,size:-1},{name:statuses,type:arc.struct.Array<mindustry.entities.units.StatusEntry>,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:vel,type:arc.math.geom.Vec2,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 994 B

After

Width:  |  Height:  |  Size: 991 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 614 B

View File

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

View File

Before

Width:  |  Height:  |  Size: 468 B

After

Width:  |  Height:  |  Size: 468 B

View File

Before

Width:  |  Height:  |  Size: 490 B

After

Width:  |  Height:  |  Size: 490 B

View File

Before

Width:  |  Height:  |  Size: 465 B

After

Width:  |  Height:  |  Size: 465 B

View File

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

Before

Width:  |  Height:  |  Size: 445 B

After

Width:  |  Height:  |  Size: 445 B

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 734 KiB

After

Width:  |  Height:  |  Size: 736 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 127 KiB

After

Width:  |  Height:  |  Size: 128 KiB

View File

@ -82,6 +82,8 @@ public class Vars implements Loadable{
public static final float buildingRange = 220f;
/** duration of one turn in ticks */
public static final float turnDuration = 5 * Time.toMinutes;
/** min armor fraction damage */
public static final float minArmorDamage = 0.05f;
/** for map generator dialog */
public static boolean updateEditorOnChange = false;
/** size of tiles in units */

View File

@ -23,7 +23,7 @@ public class StatusEffects implements ContentList{
init(() -> {
opposite(wet,freezing);
trans(tarred, ((unit, time, newTime, result) -> {
unit.damage(8f);
unit.damagePierce(8f);
Fx.burning.at(unit.x() + Mathf.range(unit.bounds() / 2f), unit.y() + Mathf.range(unit.bounds() / 2f));
result.set(this, Math.min(time + newTime, 300f));
}));
@ -39,7 +39,7 @@ public class StatusEffects implements ContentList{
opposite(melting, burning);
trans(blasted, ((unit, time, newTime, result) -> {
unit.damage(18f);
unit.damagePierce(18f);
result.set(this, time);
}));
});
@ -52,7 +52,7 @@ public class StatusEffects implements ContentList{
init(() -> {
trans(shocked, ((unit, time, newTime, result) -> {
unit.damage(20f);
unit.damagePierce(20f);
if(unit.team() == state.rules.waveTeam){
Events.fire(Trigger.shock);
}

View File

@ -34,7 +34,7 @@ public class UnitTypes implements ContentList{
hitsize = 8f;
mass = 1.75f;
health = 130;
weapons.add(new Weapon("chain-blaster"){{
weapons.add(new Weapon("large-weapon"){{
reload = 14f;
x = 4f;
alternate = true;
@ -61,7 +61,6 @@ public class UnitTypes implements ContentList{
ejectEffect = Fx.none;
bullet = Bullets.basicFlame;
}});
}};
crawler = new UnitType("crawler"){{
@ -205,7 +204,7 @@ public class UnitTypes implements ContentList{
mass = 1.75f;
health = 130;
immunities = ObjectSet.with(StatusEffects.wet);
weapons.add(new Weapon("chain-blaster"){{
weapons.add(new Weapon("large-weapon"){{
reload = 10f;
x = 1.25f;
alternate = true;
@ -277,7 +276,7 @@ public class UnitTypes implements ContentList{
buildSpeed = 0.9f;
canBoost = true;
weapons.add(new Weapon("shockgun"){{
weapons.add(new Weapon("beam-weapon"){{
shake = 2f;
shootY = 1f;
x = 1f;
@ -474,7 +473,7 @@ public class UnitTypes implements ContentList{
engineColor = Pal.lightTrail;
cellTrnsY = 1f;
buildSpeed = 1.2f;
weapons.add(new Weapon("vanguard-blaster"){{
weapons.add(new Weapon("vanguard-gun"){{
length = 1.5f;
reload = 30f;
alternate = true;
@ -605,7 +604,7 @@ public class UnitTypes implements ContentList{
buildSpeed = 1.6f;
engineColor = Pal.heal;
weapons.add(new Weapon("heal-blaster"){{
weapons.add(new Weapon("heal-gun"){{
length = 1.5f;
reload = 24f;
alternate = false;
@ -726,7 +725,7 @@ public class UnitTypes implements ContentList{
engineColor = Pal.lightTrail;
cellTrnsY = 1f;
buildSpeed = 1.1f;
weapons.add(new Weapon("blaster"){{
weapons.add(new Weapon("gun"){{
length = 1.5f;
reload = 15f;
alternate = true;
@ -797,7 +796,7 @@ public class UnitTypes implements ContentList{
@Override
public void update(Playerc player){
float scl = scld(player);
if(Mathf.chance(Time.delta() * (0.15 * scl))){
if(Mathf.chanceDelta((0.15 * scl))){
Fx.hitLancer.at(Pal.lancerLaser, player.x, player.y);
Lightning.create(player.team(), Pal.lancerLaser, 10f * Vars.state.rules.playerDamageMultiplier,
player.x + player.vel().x, player.y + player.vel().y, player.rotation, 14);

View File

@ -26,7 +26,7 @@ public class MissileBulletType extends BasicBulletType{
public void update(Bulletc b){
super.update(b);
if(Mathf.chance(Time.delta() * 0.2)){
if(Mathf.chanceDelta(0.2)){
Fx.missileTrail.at(b.x(), b.y(), 2f, trailColor);
}
}

View File

@ -78,7 +78,7 @@ abstract class FlyingComp implements Posc, Velc, Healthc, Hitboxc{
if(canDrown() && floor.isLiquid && floor.drownTime > 0){
drownTime += Time.delta() * 1f / floor.drownTime;
drownTime = Mathf.clamp(drownTime);
if(Mathf.chance(Time.delta() * 0.05f)){
if(Mathf.chanceDelta(0.05f)){
floor.drownUpdateEffect.at(x, y, 0f, floor.mapColor);
}

View File

@ -2,6 +2,7 @@ package mindustry.entities.comp;
import arc.math.*;
import arc.util.*;
import mindustry.*;
import mindustry.annotations.Annotations.*;
import mindustry.gen.*;
@ -49,6 +50,20 @@ abstract class HealthComp implements Entityc{
return health < maxHealth - 0.001f;
}
/** Damage and pierce armor. */
void damagePierce(float amount, boolean withEffect){
if(this instanceof Shieldc){
damage(amount / Math.max(1f - ((Shieldc)this).armor(), Vars.minArmorDamage), withEffect);
}else{
damage(amount, withEffect);
}
}
/** Damage and pierce armor. */
void damagePierce(float amount){
damagePierce(amount, true);
}
void damage(float amount){
health -= amount;
hitTime = 1f;
@ -71,6 +86,10 @@ abstract class HealthComp implements Entityc{
damage(amount * Time.delta(), hitTime <= -20 + hitDuration);
}
void damageContinuousPierce(float amount){
damagePierce(amount * Time.delta(), hitTime <= -20 + hitDuration);
}
void clampHealth(){
health = Mathf.clamp(health, 0, maxHealth);
}

View File

@ -5,19 +5,26 @@ import mindustry.annotations.Annotations.*;
import mindustry.content.*;
import mindustry.gen.*;
import static mindustry.Vars.minArmorDamage;
@Component
abstract class ShieldComp implements Healthc, Posc{
@Import float health, hitTime;
@Import float health, hitTime, x, y;
@Import boolean dead;
/** Absorbs health damage. */
float shield;
/** Absorbs percentage of damage, up to 90% */
float armor;
/** Shield opacity. */
transient float shieldAlpha = 0f;
@Replace
@Override
public void damage(float amount){
//apply armor
amount *= Math.max(1f - armor, minArmorDamage);
hitTime = 1f;
boolean hadShields = shield > 0.0001f;
@ -37,7 +44,7 @@ abstract class ShieldComp implements Healthc, Posc{
}
if(hadShields && shield <= 0.0001f){
Fx.unitShieldBreak.at(x(), y(), 0, this);
Fx.unitShieldBreak.at(x, y, 0, this);
}
}
}

View File

@ -116,7 +116,7 @@ public class Stats{
//weigh used fractions
float frac = 0f;
Array<Item> obtainable = Array.select(zone.data.resources, i -> i instanceof Item && ((Item)i).type == ItemType.material).as(Item.class);
Array<Item> obtainable = Array.select(zone.data.resources, i -> i instanceof Item && ((Item)i).type == ItemType.material).as();
for(Item item : obtainable){
frac += Mathf.clamp((float)itemsDelivered.get(item, 0) / capacity) / (float)obtainable.size;
}

View File

@ -46,13 +46,13 @@ public class StatusEffect extends MappableContent{
/** Runs every tick on the affected unit while time is greater than 0. */
public void update(Unitc unit, float time){
if(damage > 0){
unit.damageContinuous(damage);
unit.damageContinuousPierce(damage);
}else if(damage < 0){ //heal unit
unit.heal(damage * Time.delta());
}
if(effect != Fx.none && Mathf.chance(Time.delta() * 0.15f)){
effect.at(unit.getX() + Mathf.range(unit.bounds() / 2f), unit.getY() + Mathf.range(unit.bounds() / 2f));
if(effect != Fx.none && Mathf.chanceDelta(0.15f)){
effect.at(unit.x() + Mathf.range(unit.bounds() / 2f), unit.y() + Mathf.range(unit.bounds() / 2f));
}
}

View File

@ -32,7 +32,7 @@ public class UnitType extends UnlockableContent{
public @NonNull Prov<? extends UnitController> defaultController = () -> !flying ? new GroundAI() : new FlyingAI();
public float speed = 1.1f, boostMultiplier = 1f, rotateSpeed = 5f, baseRotateSpeed = 5f;
public float drag = 0.3f, mass = 1f, accel = 0.5f, landShake = 0f;
public float health = 200f, range = -1;
public float health = 200f, range = -1, armor = 0f;
public boolean targetAir = true, targetGround = true;
public boolean faceTarget = true, isCounted = true, lowAltitude = false;
public boolean canBoost = false;
@ -76,6 +76,7 @@ public class UnitType extends UnlockableContent{
public Unitc create(Team team){
Unitc unit = constructor.get();
unit.team(team);
unit.armor(armor);
unit.type(this);
return unit;
}

View File

@ -98,7 +98,7 @@ public class ForceProjector extends Block{
radscl = Mathf.lerpDelta(radscl, broken ? 0f : warmup, 0.05f);
if(Mathf.chance(Time.delta() * buildup / breakage * 0.1f)){
if(Mathf.chanceDelta(buildup / breakage * 0.1f)){
Fx.reactorsmoke.at(x + Mathf.range(tilesize / 2f), y + Mathf.range(tilesize / 2f));
}

View File

@ -272,7 +272,7 @@ public class Drill extends Block{
warmup = Mathf.lerpDelta(warmup, speed, warmupSpeed);
progress += delta() * dominantItems * speed * warmup;
if(Mathf.chance(Time.delta() * updateEffectChance * warmup))
if(Mathf.chanceDelta(updateEffectChance * warmup))
updateEffect.at(getX() + Mathf.range(size * 2f), getY() + Mathf.range(size * 2f));
}else{
lastDrillSpeed = 0f;

View File

@ -101,7 +101,7 @@ public class GenericCrafter extends Block{
totalProgress += delta();
warmup = Mathf.lerpDelta(warmup, 1f, 0.02f);
if(Mathf.chance(Time.delta() * updateEffectChance)){
if(Mathf.chanceDelta(updateEffectChance)){
updateEffect.at(getX() + Mathf.range(size * 4f), getY() + Mathf.range(size * 4));
}
}else{

View File

@ -1,3 +1,3 @@
org.gradle.daemon=true
org.gradle.jvmargs=-Xms256m -Xmx1024m
archash=6f712c9333d9415f0184c7d0eb72eec2db095126
archash=49d06244c138d0c0083539760fbf643791125e6d

View File

@ -34,7 +34,7 @@ task debug(dependsOn: classes, type: JavaExec){
task dist(type: Jar){
from files(sourceSets.main.output.classesDirs)
from files(sourceSets.main.output.resourcesDir)
from {configurations.compile.collect{ it.isDirectory() ? it : zipTree(it) }}
from {configurations.runtimeClasspath.collect{ it.isDirectory() ? it : zipTree(it) }}
from files(project.assetsDir)
exclude("sprites/**")
exclude("music/**")