Unit AI fixes / Other general fixes
This commit is contained in:
@@ -180,6 +180,7 @@ public class UnitTypes implements ContentList{
|
||||
isFlying = true;
|
||||
health = 75;
|
||||
engineOffset = 5.5f;
|
||||
range = 140f;
|
||||
weapon = new Weapon("chain-blaster"){{
|
||||
length = 1.5f;
|
||||
reload = 28f;
|
||||
@@ -198,6 +199,7 @@ public class UnitTypes implements ContentList{
|
||||
isFlying = true;
|
||||
targetAir = false;
|
||||
engineOffset = 7.8f;
|
||||
range = 140f;
|
||||
weapon = new Weapon("bomber"){{
|
||||
length = 0f;
|
||||
width = 2f;
|
||||
|
||||
@@ -248,6 +248,7 @@ public class NetClient implements ApplicationListener{
|
||||
for(int i = 0; i < cores; i++){
|
||||
int pos = input.readInt();
|
||||
Tile tile = world.tile(pos);
|
||||
|
||||
if(tile != null && tile.entity != null){
|
||||
tile.entity.items.read(input);
|
||||
}else{
|
||||
|
||||
@@ -129,7 +129,10 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
||||
}
|
||||
|
||||
public void targetClosest(){
|
||||
target = Units.getClosestTarget(team, x, y, Math.max(getWeapon().bullet.range(), type.range), u -> type.targetAir || !u.isFlying());
|
||||
TargetTrait newTarget = Units.getClosestTarget(team, x, y, Math.max(getWeapon().bullet.range(), type.range), u -> type.targetAir || !u.isFlying());
|
||||
if(newTarget != null){
|
||||
target = newTarget;
|
||||
}
|
||||
}
|
||||
|
||||
public TileEntity getClosestEnemyCore(){
|
||||
|
||||
@@ -47,7 +47,7 @@ public abstract class FlyingUnit extends BaseUnit{
|
||||
attack(type.attackLength);
|
||||
|
||||
if((Angles.near(angleTo(target), rotation, type.shootCone) || getWeapon().ignoreRotation) //bombers and such don't care about rotation
|
||||
&& dst(target) < Math.max(getWeapon().bullet.range(), type.range)){
|
||||
&& dst(target) < getWeapon().bullet.range()){
|
||||
BulletType ammo = getWeapon().bullet;
|
||||
|
||||
if(type.rotateWeapon){
|
||||
@@ -75,8 +75,9 @@ public abstract class FlyingUnit extends BaseUnit{
|
||||
targetClosest();
|
||||
targetClosestEnemyFlag(BlockFlag.target);
|
||||
|
||||
if(target != null){
|
||||
if(target != null && !Units.invalidateTarget(target, team, x, y)){
|
||||
setState(attack);
|
||||
return;
|
||||
}
|
||||
|
||||
target = getClosestCore();
|
||||
|
||||
@@ -54,10 +54,11 @@ public abstract class GroundUnit extends BaseUnit{
|
||||
patrol = new UnitState(){
|
||||
public void update(){
|
||||
TileEntity target = getClosestCore();
|
||||
|
||||
if(target != null){
|
||||
if(dst(target) > 400f){
|
||||
moveAwayFromCore();
|
||||
}else{
|
||||
}else if(!(!Units.invalidateTarget(GroundUnit.this.target, GroundUnit.this) && dst(GroundUnit.this.target) < getWeapon().bullet.range())){
|
||||
patrol();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,6 +63,10 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{
|
||||
public static void onTileDamage(Tile tile, float health){
|
||||
if(tile.entity != null){
|
||||
tile.entity.health = health;
|
||||
|
||||
if(tile.entity.damaged()){
|
||||
world.indexer.notifyTileDamaged(tile.entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,7 +155,9 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{
|
||||
|
||||
if(health <= 0){
|
||||
Call.onTileDestroyed(tile);
|
||||
}else if(preHealth >= maxHealth() - 0.00001f && health < maxHealth() && world != null){ //when just damaged
|
||||
}
|
||||
|
||||
if(preHealth >= maxHealth() - 0.00001f && health < maxHealth() && world != null){ //when just damaged
|
||||
world.indexer.notifyTileDamaged(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,7 +229,9 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
}
|
||||
Draw.color();
|
||||
}else{
|
||||
float rad = (tile.block().size * tilesize / 2f - 1) * request.scale;
|
||||
float rad = Math.max((tile.block().size * tilesize / 2f - 1) * request.scale, 1f);
|
||||
|
||||
if(rad <= 1.01f) return;
|
||||
Draw.mixcol();
|
||||
//draw removing request
|
||||
Draw.tint(Pal.removeBack);
|
||||
|
||||
Reference in New Issue
Block a user