This commit is contained in:
Anuken
2020-10-10 15:50:03 -04:00
parent 316e6e298c
commit c2202a0173
4 changed files with 42 additions and 33 deletions

View File

@@ -6,6 +6,8 @@ import mindustry.entities.*;
import mindustry.entities.units.*;
import mindustry.gen.*;
import mindustry.world.*;
import mindustry.world.blocks.distribution.*;
import mindustry.world.blocks.liquid.*;
import mindustry.world.meta.*;
public class SuicideAI extends GroundAI{
@@ -14,7 +16,7 @@ public class SuicideAI extends GroundAI{
@Override
public void updateUnit(){
if(Units.invalidateTarget(target, unit.team(), unit.x(), unit.y(), Float.MAX_VALUE)){
if(Units.invalidateTarget(target, unit.team, unit.x, unit.y, Float.MAX_VALUE)){
target = null;
}
@@ -35,29 +37,32 @@ public class SuicideAI extends GroundAI{
unit.aimLook(Predict.intercept(unit, target, unit.type().weapons.first().bullet.speed));
}
blockedByBlock = false;
//do not move toward walls or transport blocks
if(!(target instanceof Building build && (build.block.group == BlockGroup.walls || build.block.group == BlockGroup.liquids || build.block.group == BlockGroup.transportation))){
blockedByBlock = false;
//raycast for target
boolean blocked = Vars.world.raycast(unit.tileX(), unit.tileY(), target.tileX(), target.tileY(), (x, y) -> {
Tile tile = Vars.world.tile(x, y);
if(tile != null && tile.build == target) return false;
if(tile != null && tile.build != null && tile.build.team != unit.team()){
blockedByBlock = true;
return true;
}else{
return tile == null || tile.solid();
//raycast for target
boolean blocked = Vars.world.raycast(unit.tileX(), unit.tileY(), target.tileX(), target.tileY(), (x, y) -> {
Tile tile = Vars.world.tile(x, y);
if(tile != null && tile.build == target) return false;
if(tile != null && tile.build != null && tile.build.team != unit.team()){
blockedByBlock = true;
return true;
}else{
return tile == null || tile.solid();
}
});
//shoot when there's an enemy block in the way
if(blockedByBlock){
shoot = true;
}
});
//shoot when there's an enemy block in the way
if(blockedByBlock){
shoot = true;
}
if(!blocked){
moveToTarget = true;
//move towards target directly
unit.moveAt(vec.set(target).sub(unit).limit(unit.type().speed));
if(!blocked){
moveToTarget = true;
//move towards target directly
unit.moveAt(vec.set(target).sub(unit).limit(unit.type().speed));
}
}
}
@@ -78,4 +83,10 @@ public class SuicideAI extends GroundAI{
unit.controlWeapons(rotate, shoot);
}
@Override
protected Teamc target(float x, float y, float range, boolean air, boolean ground){
return Units.closestTarget(unit.team, x, y, range, u -> u.checkTarget(air, ground), t -> ground &&
!(t.block instanceof Conveyor || t.block instanceof Conduit)); //do not target conveyors/conduits
}
}

View File

@@ -514,7 +514,7 @@ public class UnitTypes implements ContentList{
crawler = new UnitType("crawler"){{
defaultController = SuicideAI::new;
speed = 0.92f;
speed = 1f;
hitSize = 8f;
health = 180;
mechSideSway = 0.25f;
@@ -529,9 +529,9 @@ public class UnitTypes implements ContentList{
hitEffect = Fx.pulverize;
lifetime = 10f;
speed = 1f;
splashDamageRadius = 55f;
splashDamageRadius = 70f;
instantDisappear = true;
splashDamage = 60f;
splashDamage = 80f;
killShooter = true;
hittable = false;
collidesAir = true;
@@ -1187,8 +1187,6 @@ public class UnitTypes implements ContentList{
healPercent = 5.5f;
collidesTeam = true;
backColor = Pal.heal;
frontColor = Color.white;
backColor = Pal.heal;
trailColor = Pal.heal;
}};
}});
@@ -1233,7 +1231,7 @@ public class UnitTypes implements ContentList{
}};
quad = new UnitType("quad"){{
armor = 4f;
armor = 6f;
health = 6000;
speed = 1.2f;
rotateSpeed = 2f;
@@ -1256,7 +1254,7 @@ public class UnitTypes implements ContentList{
new Weapon(){{
x = y = 0f;
mirror = false;
reload = 60f;
reload = 55f;
minShootVelocity = 0.01f;
bullet = new BasicBulletType(){{
@@ -1289,9 +1287,9 @@ public class UnitTypes implements ContentList{
speed = 0.001f;
collides = false;
healPercent = 10f;
splashDamage = 240f;
splashDamageRadius = 115f;
healPercent = 15f;
splashDamage = 320f;
splashDamageRadius = 120f;
}};
}});
}};

View File

@@ -603,7 +603,7 @@ public class ContentParser{
customRequirements = null;
}else{
researchName = research.getString("parent");
customRequirements = research.hasChild("requirements") ? parser.readValue(ItemStack[].class, research.getChild("requirements")) : null;
customRequirements = research.has("requirements") ? parser.readValue(ItemStack[].class, research.get("requirements")) : null;
}
//remove old node

View File

@@ -34,7 +34,7 @@ public class Wall extends Block{
solid = true;
destructible = true;
group = BlockGroup.walls;
buildCostMultiplier = 5f;
buildCostMultiplier = 6f;
canOverdrive = false;
}