Correct quell AI
This commit is contained in:
62
core/src/mindustry/ai/types/FlyingFollowAI.java
Normal file
62
core/src/mindustry/ai/types/FlyingFollowAI.java
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
package mindustry.ai.types;
|
||||||
|
|
||||||
|
import arc.math.*;
|
||||||
|
import arc.util.*;
|
||||||
|
import mindustry.*;
|
||||||
|
import mindustry.entities.*;
|
||||||
|
import mindustry.entities.units.*;
|
||||||
|
import mindustry.gen.*;
|
||||||
|
|
||||||
|
/** AI/wave team only! This is used for wave support flyers. */
|
||||||
|
public class FlyingFollowAI extends FlyingAI{
|
||||||
|
public Teamc following;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateMovement(){
|
||||||
|
unloadPayloads();
|
||||||
|
|
||||||
|
if(following != null){
|
||||||
|
moveTo(following, (following instanceof Sized s ? s.hitSize()/2f * 1.1f : 0f) + unit.hitSize/2f + 15f, 50f);
|
||||||
|
}else if(target != null && unit.hasWeapons()){
|
||||||
|
moveTo(target, 80f);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(shouldFaceTarget()){
|
||||||
|
unit.lookAt(target);
|
||||||
|
Log.info("lookAt target = @", target);
|
||||||
|
}else if(following != null){
|
||||||
|
unit.lookAt(following);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(timer.get(timerTarget3, 30f)){
|
||||||
|
following = Units.closest(unit.team, unit.x, unit.y, Math.max(unit.type.range, 400f), u -> !u.dead() && u.type != unit.type, (u, tx, ty) -> -u.maxHealth + Mathf.dst2(u.x, u.y, tx, ty) / 6400f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean shouldFaceTarget(){
|
||||||
|
return target != null && (following == null || unit.within(target, unit.range()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateVisuals(){
|
||||||
|
if(unit.isFlying()){
|
||||||
|
unit.wobble();
|
||||||
|
|
||||||
|
if(!shouldFaceTarget()){
|
||||||
|
unit.lookAt(unit.prefRotation());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AIController fallback(){
|
||||||
|
return new FlyingAI();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean useFallback(){
|
||||||
|
//only AI teams use this controller
|
||||||
|
return Vars.state.rules.pvp || Vars.state.rules.waveTeam != unit.team;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -2603,6 +2603,7 @@ public class UnitTypes{
|
|||||||
//region erekir - flying
|
//region erekir - flying
|
||||||
|
|
||||||
quell = new UnitType("quell"){{
|
quell = new UnitType("quell"){{
|
||||||
|
defaultController = FlyingFollowAI::new;
|
||||||
envDisabled = 0;
|
envDisabled = 0;
|
||||||
|
|
||||||
outlineColor = Pal.darkOutline;
|
outlineColor = Pal.darkOutline;
|
||||||
@@ -2639,6 +2640,8 @@ public class UnitTypes{
|
|||||||
shootEffect = Fx.shootBig;
|
shootEffect = Fx.shootBig;
|
||||||
smokeEffect = Fx.shootBigSmoke2;
|
smokeEffect = Fx.shootBigSmoke2;
|
||||||
shake = 1f;
|
shake = 1f;
|
||||||
|
speed = 0f;
|
||||||
|
keepVelocity = false;
|
||||||
}};
|
}};
|
||||||
|
|
||||||
unitSpawned = new MissileUnitType("quell-missile"){{
|
unitSpawned = new MissileUnitType("quell-missile"){{
|
||||||
|
|||||||
@@ -125,6 +125,7 @@ public class AIController implements UnitController{
|
|||||||
|
|
||||||
for(var mount : unit.mounts){
|
for(var mount : unit.mounts){
|
||||||
Weapon weapon = mount.weapon;
|
Weapon weapon = mount.weapon;
|
||||||
|
float wrange = weapon.range();
|
||||||
|
|
||||||
//let uncontrollable weapons do their own thing
|
//let uncontrollable weapons do their own thing
|
||||||
if(!weapon.controllable) continue;
|
if(!weapon.controllable) continue;
|
||||||
@@ -136,10 +137,10 @@ public class AIController implements UnitController{
|
|||||||
mount.target = target;
|
mount.target = target;
|
||||||
}else{
|
}else{
|
||||||
if(ret){
|
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;
|
mount.target = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -147,7 +148,7 @@ public class AIController implements UnitController{
|
|||||||
boolean shoot = false;
|
boolean shoot = false;
|
||||||
|
|
||||||
if(mount.target != null){
|
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);
|
Vec2 to = Predict.intercept(unit, mount.target, weapon.bullet.speed);
|
||||||
mount.aimX = to.x;
|
mount.aimX = to.x;
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import mindustry.world.meta.*;
|
|||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
public class ErekirPlanetGenerator extends PlanetGenerator{
|
public class ErekirPlanetGenerator extends PlanetGenerator{
|
||||||
//public float scl = 2f;
|
|
||||||
public float heightScl = 0.9f, octaves = 8, persistence = 0.7f, heightPow = 3f, heightMult = 1.6f;
|
public float heightScl = 0.9f, octaves = 8, persistence = 0.7f, heightPow = 3f, heightMult = 1.6f;
|
||||||
|
|
||||||
//TODO inline/remove
|
//TODO inline/remove
|
||||||
@@ -407,6 +406,8 @@ public class ErekirPlanetGenerator extends PlanetGenerator{
|
|||||||
//it is very hot
|
//it is very hot
|
||||||
state.rules.attributes.set(Attribute.heat, 0.8f);
|
state.rules.attributes.set(Attribute.heat, 0.8f);
|
||||||
state.rules.environment = sector.planet.defaultEnv;
|
state.rules.environment = sector.planet.defaultEnv;
|
||||||
|
|
||||||
|
//TODO remove slag and arkycite around core.
|
||||||
Schematics.placeLaunchLoadout(spawnX, spawnY);
|
Schematics.placeLaunchLoadout(spawnX, spawnY);
|
||||||
|
|
||||||
//all sectors are wave sectors
|
//all sectors are wave sectors
|
||||||
|
|||||||
@@ -417,8 +417,8 @@ public class UnitType extends UnlockableContent{
|
|||||||
if(range < 0){
|
if(range < 0){
|
||||||
range = Float.MAX_VALUE;
|
range = Float.MAX_VALUE;
|
||||||
for(Weapon weapon : weapons){
|
for(Weapon weapon : weapons){
|
||||||
range = Math.min(range, weapon.bullet.range() - margin);
|
range = Math.min(range, weapon.range() - margin);
|
||||||
maxRange = Math.max(maxRange, weapon.bullet.range() - margin);
|
maxRange = Math.max(maxRange, weapon.range() - margin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -426,7 +426,7 @@ public class UnitType extends UnlockableContent{
|
|||||||
maxRange = Math.max(0f, range);
|
maxRange = Math.max(0f, range);
|
||||||
|
|
||||||
for(Weapon weapon : weapons){
|
for(Weapon weapon : weapons){
|
||||||
maxRange = Math.max(maxRange, weapon.bullet.range() - margin);
|
maxRange = Math.max(maxRange, weapon.range() - margin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -216,6 +216,10 @@ public class Weapon implements Cloneable{
|
|||||||
Draw.z(z);
|
Draw.z(z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float range(){
|
||||||
|
return unitSpawned != null ? unitSpawned.lifetime * unitSpawned.speed : bullet.range();
|
||||||
|
}
|
||||||
|
|
||||||
public void update(Unit unit, WeaponMount mount){
|
public void update(Unit unit, WeaponMount mount){
|
||||||
boolean can = unit.canShoot();
|
boolean can = unit.canShoot();
|
||||||
float lastReload = mount.reload;
|
float lastReload = mount.reload;
|
||||||
|
|||||||
Reference in New Issue
Block a user