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

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

View File

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

View File

@@ -53,7 +53,9 @@ public class Predict{
* See {@link #intercept(float, float, float, float, float, float, float)}.
*/
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){

View File

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

View File

@@ -2,6 +2,7 @@ package io.anuke.mindustry.entities.traits;
import io.anuke.mindustry.game.Team;
import io.anuke.ucore.entities.trait.PosTrait;
import io.anuke.ucore.entities.trait.SolidTrait;
import io.anuke.ucore.entities.trait.VelocityTrait;
/**
@@ -13,6 +14,22 @@ public interface TargetTrait extends PosTrait, VelocityTrait{
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.
*/

View File

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