Improved turret accuracy

This commit is contained in:
Anuken
2018-09-13 16:53:05 -04:00
parent 6d47b449b9
commit 0776951018
7 changed files with 38 additions and 4 deletions

View File

@@ -27,7 +27,7 @@ allprojects {
appName = 'Mindustry' appName = 'Mindustry'
gdxVersion = '1.9.8' gdxVersion = '1.9.8'
roboVMVersion = '2.3.0' roboVMVersion = '2.3.0'
uCoreVersion = '74dc653bbd66d1e8b10e22efb4f1206195674dd5' uCoreVersion = 'cf9553e76e6226650b86921a73208e360049ba44'
getVersionString = { getVersionString = {
String buildVersion = getBuildVersion() String buildVersion = getBuildVersion()

View File

@@ -217,9 +217,10 @@ public class TurretBlocks extends BlockList implements ContentList{
spectre = new DoubleTurret("spectre"){{ spectre = new DoubleTurret("spectre"){{
ammoTypes = new AmmoType[]{AmmoTypes.bulletDenseBig, AmmoTypes.bulletPyratiteBig, AmmoTypes.bulletThoriumBig}; ammoTypes = new AmmoType[]{AmmoTypes.bulletDenseBig, AmmoTypes.bulletPyratiteBig, AmmoTypes.bulletThoriumBig};
reload = 4f; reload = 4f;
restitution = 0.03f; restitution = 0.1f;
ammoUseEffect = ShootFx.shellEjectMedium; ammoUseEffect = ShootFx.shellEjectMedium;
range = 200f; range = 200f;
inaccuracy = 4f;
recoil = 3f; recoil = 3f;
xRand = 3f; xRand = 3f;
shotWidth = 4f; shotWidth = 4f;

View File

@@ -102,6 +102,11 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
player.onDeath(); player.onDeath();
} }
@Override
public float getDrag(){
return mech.drag;
}
@Override @Override
public Timer getTimer(){ public Timer getTimer(){
return timer; return timer;
@@ -431,6 +436,8 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
//region update methods //region update methods
float lastx, lasty;
@Override @Override
public void update(){ public void update(){
hitTime -= Timers.delta(); hitTime -= Timers.delta();

View File

@@ -53,7 +53,9 @@ public class Predict{
* See {@link #intercept(float, float, float, float, float, float, float)}. * See {@link #intercept(float, float, float, float, float, float, float)}.
*/ */
public static Vector2 intercept(TargetTrait src, TargetTrait dst, float v){ public static Vector2 intercept(TargetTrait src, TargetTrait dst, float v){
return intercept(src.getX(), src.getY(), dst.getX(), dst.getY(), dst.getVelocity().x - src.getVelocity().x, dst.getVelocity().x - src.getVelocity().y, v); return intercept(src.getX(), src.getY(), dst.getX(), dst.getY(),
dst.getTargetVelocityX() - src.getTargetVelocityX(),
dst.getTargetVelocityY() - src.getTargetVelocityY(), v);
} }
private static Vector2 quad(float a, float b, float c){ private static Vector2 quad(float a, float b, float c){

View File

@@ -207,13 +207,15 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
/**Updates velocity and status effects.*/ /**Updates velocity and status effects.*/
public void updateVelocityStatus(float drag, float maxVelocity){ public void updateVelocityStatus(float drag, float maxVelocity){
Floor floor = getFloorOn();
if(isCarried()){ //carried units do not take into account velocity normally if(isCarried()){ //carried units do not take into account velocity normally
set(carrier.getX(), carrier.getY()); set(carrier.getX(), carrier.getY());
velocity.set(carrier.getVelocity()); velocity.set(carrier.getVelocity());
return; return;
} }
Floor floor = getFloorOn();
Tile tile = world.tileWorld(x, y); Tile tile = world.tileWorld(x, y);
status.update(this); status.update(this);

View File

@@ -2,6 +2,7 @@ package io.anuke.mindustry.entities.traits;
import io.anuke.mindustry.game.Team; import io.anuke.mindustry.game.Team;
import io.anuke.ucore.entities.trait.PosTrait; import io.anuke.ucore.entities.trait.PosTrait;
import io.anuke.ucore.entities.trait.SolidTrait;
import io.anuke.ucore.entities.trait.VelocityTrait; import io.anuke.ucore.entities.trait.VelocityTrait;
/** /**
@@ -13,6 +14,22 @@ public interface TargetTrait extends PosTrait, VelocityTrait{
Team getTeam(); Team getTeam();
default float getTargetVelocityX(){
if(this instanceof SolidTrait){
return getX() - ((SolidTrait) this).lastPosition().x;
}else{
return getVelocity().x;
}
}
default float getTargetVelocityY(){
if(this instanceof SolidTrait){
return getY() - ((SolidTrait) this).lastPosition().y;
}else{
return getVelocity().y;
}
}
/** /**
* Whether this entity is a valid target. * Whether this entity is a valid target.
*/ */

View File

@@ -82,6 +82,11 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
threads.runDelay(unit::remove); threads.runDelay(unit::remove);
} }
@Override
public float getDrag(){
return type.drag;
}
/**Called when a command is recieved from the command center.*/ /**Called when a command is recieved from the command center.*/
public abstract void onCommand(UnitCommand command); public abstract void onCommand(UnitCommand command);