Removed AmmoType class completely
This commit is contained in:
@@ -629,7 +629,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
|
||||
protected void updateFlying(){
|
||||
if(Units.invalidateTarget(target, this) && !(target instanceof TileEntity && ((TileEntity) target).damaged() && target.getTeam() == team &&
|
||||
mech.canHeal && dst(target) < getWeapon().getAmmo().getRange())){
|
||||
mech.canHeal && dst(target) < getWeapon().getAmmo().range())){
|
||||
target = null;
|
||||
}
|
||||
|
||||
@@ -709,11 +709,11 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
if(target == null){
|
||||
isShooting = false;
|
||||
if(Core.settings.getBool("autotarget")){
|
||||
target = Units.getClosestTarget(team, x, y, getWeapon().getAmmo().getRange());
|
||||
target = Units.getClosestTarget(team, x, y, getWeapon().getAmmo().range());
|
||||
|
||||
if(mech.canHeal && target == null){
|
||||
target = Geometry.findClosest(x, y, world.indexer.getDamaged(Team.blue));
|
||||
if(target != null && dst(target) > getWeapon().getAmmo().getRange()){
|
||||
if(target != null && dst(target) > getWeapon().getAmmo().range()){
|
||||
target = null;
|
||||
}else if(target != null){
|
||||
target = ((Tile) target).entity;
|
||||
@@ -725,14 +725,14 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
}
|
||||
}
|
||||
}else if(target.isValid() || (target instanceof TileEntity && ((TileEntity) target).damaged() && target.getTeam() == team &&
|
||||
mech.canHeal && dst(target) < getWeapon().getAmmo().getRange())){
|
||||
mech.canHeal && dst(target) < getWeapon().getAmmo().range())){
|
||||
//rotate toward and shoot the target
|
||||
if(mech.turnCursor){
|
||||
rotation = Mathf.slerpDelta(rotation, angleTo(target), 0.2f);
|
||||
}
|
||||
|
||||
Vector2 intercept =
|
||||
Predict.intercept(x, y, target.getX(), target.getY(), target.velocity().x - velocity.x, target.velocity().y - velocity.y, getWeapon().getAmmo().bullet.speed);
|
||||
Predict.intercept(x, y, target.getX(), target.getY(), target.velocity().x - velocity.x, target.velocity().y - velocity.y, getWeapon().getAmmo().speed);
|
||||
|
||||
pointerX = intercept.x;
|
||||
pointerY = intercept.y;
|
||||
|
||||
@@ -48,7 +48,7 @@ public class Units{
|
||||
|
||||
/**See {@link #invalidateTarget(TargetTrait, Team, float, float, float)}*/
|
||||
public static boolean invalidateTarget(TargetTrait target, Unit targeter){
|
||||
return invalidateTarget(target, targeter.team, targeter.x, targeter.y, targeter.getWeapon().getAmmo().getRange());
|
||||
return invalidateTarget(target, targeter.team, targeter.x, targeter.y, targeter.getWeapon().getAmmo().range());
|
||||
}
|
||||
|
||||
/**Returns whether there are any entities on this tile.*/
|
||||
|
||||
@@ -13,9 +13,7 @@ import io.anuke.mindustry.entities.Units;
|
||||
import io.anuke.mindustry.entities.traits.TargetTrait;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
|
||||
/**
|
||||
* A BulletType for most ammo-based bullets shot from turrets and units.
|
||||
*/
|
||||
/**An extended BulletType for most ammo-based bullets shot from turrets and units.*/
|
||||
public class BasicBulletType extends BulletType{
|
||||
public Color backColor = Palette.bulletYellowBack, frontColor = Palette.bulletYellow;
|
||||
public float bulletWidth = 5f, bulletHeight = 7f;
|
||||
|
||||
@@ -4,7 +4,7 @@ import io.anuke.arc.entities.Effects;
|
||||
import io.anuke.arc.entities.Effects.Effect;
|
||||
import io.anuke.mindustry.content.StatusEffects;
|
||||
import io.anuke.mindustry.content.fx.BulletFx;
|
||||
import io.anuke.mindustry.content.fx.Fx;
|
||||
import io.anuke.mindustry.content.fx.ShootFx;
|
||||
import io.anuke.mindustry.game.Content;
|
||||
import io.anuke.mindustry.type.ContentType;
|
||||
import io.anuke.mindustry.type.StatusEffect;
|
||||
@@ -21,9 +21,17 @@ public abstract class BulletType extends Content{
|
||||
public Effect hitEffect, despawnEffect;
|
||||
|
||||
/**Effect created when shooting.*/
|
||||
public Effect shootEffect = Fx.none;
|
||||
public Effect shootEffect = ShootFx.shootSmall;
|
||||
/**Extra smoke effect created when shooting.*/
|
||||
public Effect smokeEffect = Fx.none;
|
||||
public Effect smokeEffect = ShootFx.shootSmallSmoke;
|
||||
/**Extra inaccuracy when firing.*/
|
||||
public float inaccuracy = 0f;
|
||||
/**How many bullets get created per ammo item/liquid.*/
|
||||
public float ammoMultiplier = 1f;
|
||||
/**Multiplied by turret reload speed to get final shoot speed.*/
|
||||
public float reloadMultiplier = 1f;
|
||||
/**Recoil from shooter entities.*/
|
||||
public float recoil;
|
||||
|
||||
public float splashDamage = 0f;
|
||||
/**Knockback in velocity.*/
|
||||
@@ -57,6 +65,11 @@ public abstract class BulletType extends Content{
|
||||
despawnEffect = BulletFx.hitBulletSmall;
|
||||
}
|
||||
|
||||
/**Returns maximum distance the bullet this bullet type has can travel.*/
|
||||
public float range(){
|
||||
return speed * lifetime;
|
||||
}
|
||||
|
||||
public boolean collides(Bullet bullet, Tile tile){
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
||||
}
|
||||
|
||||
public void targetClosest(){
|
||||
target = Units.getClosestTarget(team, x, y, Math.max(getWeapon().getAmmo().getRange(), type.range), u -> type.targetAir || !u.isFlying());
|
||||
target = Units.getClosestTarget(team, x, y, Math.max(getWeapon().getAmmo().range(), type.range), u -> type.targetAir || !u.isFlying());
|
||||
}
|
||||
|
||||
public TileEntity getClosestEnemyCore(){
|
||||
|
||||
@@ -8,10 +8,10 @@ import io.anuke.arc.math.geom.Vector2;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.mindustry.entities.Predict;
|
||||
import io.anuke.mindustry.entities.Units;
|
||||
import io.anuke.mindustry.entities.bullet.BulletType;
|
||||
import io.anuke.mindustry.entities.traits.CarriableTrait;
|
||||
import io.anuke.mindustry.entities.traits.CarryTrait;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.type.AmmoType;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.meta.BlockFlag;
|
||||
|
||||
@@ -74,11 +74,11 @@ public abstract class FlyingUnit extends BaseUnit implements CarryTrait{
|
||||
}else{
|
||||
attack(150f);
|
||||
|
||||
if((Angles.near(angleTo(target), rotation, 15f) || !getWeapon().getAmmo().bullet.keepVelocity) //bombers don't care about rotation
|
||||
&& dst(target) < Math.max(getWeapon().getAmmo().getRange(), type.range)){
|
||||
AmmoType ammo = getWeapon().getAmmo();
|
||||
if((Angles.near(angleTo(target), rotation, 15f) || !getWeapon().getAmmo().keepVelocity) //bombers don't care about rotation
|
||||
&& dst(target) < Math.max(getWeapon().getAmmo().range(), type.range)){
|
||||
BulletType ammo = getWeapon().getAmmo();
|
||||
|
||||
Vector2 to = Predict.intercept(FlyingUnit.this, target, ammo.bullet.speed);
|
||||
Vector2 to = Predict.intercept(FlyingUnit.this, target, ammo.speed);
|
||||
|
||||
getWeapon().update(FlyingUnit.this, to.x, to.y);
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.entities.Predict;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.entities.Units;
|
||||
import io.anuke.mindustry.entities.bullet.BulletType;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.type.AmmoType;
|
||||
import io.anuke.mindustry.type.ContentType;
|
||||
import io.anuke.mindustry.type.Weapon;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
@@ -43,11 +43,11 @@ public abstract class GroundUnit extends BaseUnit{
|
||||
TileEntity core = getClosestEnemyCore();
|
||||
float dst = core == null ? 0 : dst(core);
|
||||
|
||||
if(core != null && dst < getWeapon().getAmmo().getRange() / 1.1f){
|
||||
if(core != null && dst < getWeapon().getAmmo().range() / 1.1f){
|
||||
target = core;
|
||||
}
|
||||
|
||||
if(dst > getWeapon().getAmmo().getRange() * 0.5f){
|
||||
if(dst > getWeapon().getAmmo().range() * 0.5f){
|
||||
moveToCore();
|
||||
}
|
||||
}
|
||||
@@ -187,13 +187,13 @@ public abstract class GroundUnit extends BaseUnit{
|
||||
}
|
||||
|
||||
if(!Units.invalidateTarget(target, this)){
|
||||
if(dst(target) < getWeapon().getAmmo().getRange()){
|
||||
if(dst(target) < getWeapon().getAmmo().range()){
|
||||
rotate(angleTo(target));
|
||||
|
||||
if(Angles.near(angleTo(target), rotation, 13f)){
|
||||
AmmoType ammo = getWeapon().getAmmo();
|
||||
BulletType ammo = getWeapon().getAmmo();
|
||||
|
||||
Vector2 to = Predict.intercept(GroundUnit.this, target, ammo.bullet.speed);
|
||||
Vector2 to = Predict.intercept(GroundUnit.this, target, ammo.speed);
|
||||
|
||||
getWeapon().update(GroundUnit.this, to.x, to.y);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user