Correct quell AI

This commit is contained in:
Anuken
2022-01-29 13:44:38 -05:00
parent 77dc453e75
commit fdfc43ce72
6 changed files with 78 additions and 7 deletions

View File

@@ -125,6 +125,7 @@ public class AIController implements UnitController{
for(var mount : unit.mounts){
Weapon weapon = mount.weapon;
float wrange = weapon.range();
//let uncontrollable weapons do their own thing
if(!weapon.controllable) continue;
@@ -136,10 +137,10 @@ public class AIController implements UnitController{
mount.target = target;
}else{
if(ret){
mount.target = findTarget(mountX, mountY, weapon.bullet.range(), weapon.bullet.collidesAir, weapon.bullet.collidesGround);
mount.target = findTarget(mountX, mountY, wrange, weapon.bullet.collidesAir, weapon.bullet.collidesGround);
}
if(checkTarget(mount.target, mountX, mountY, weapon.bullet.range())){
if(checkTarget(mount.target, mountX, mountY, wrange)){
mount.target = null;
}
}
@@ -147,7 +148,7 @@ public class AIController implements UnitController{
boolean shoot = false;
if(mount.target != null){
shoot = mount.target.within(mountX, mountY, weapon.bullet.range() + (mount.target instanceof Sized s ? s.hitSize()/2f : 0f)) && shouldShoot();
shoot = mount.target.within(mountX, mountY, wrange + (mount.target instanceof Sized s ? s.hitSize()/2f : 0f)) && shouldShoot();
Vec2 to = Predict.intercept(unit, mount.target, weapon.bullet.speed);
mount.aimX = to.x;