mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-30 14:39:10 +07:00
Fixed omnidirectional shooting with ignored rotation
This commit is contained in:
@ -520,6 +520,7 @@ public class EntityProcess extends BaseProcessor{
|
||||
.returns(int.class).addModifiers(Modifier.PUBLIC).addStatement("return " + def.classID).build());
|
||||
}
|
||||
|
||||
|
||||
idBuilder.addStaticBlock(idStore.build());
|
||||
|
||||
write(idBuilder);
|
||||
|
@ -31,7 +31,7 @@ public class UnitTypes implements ContentList{
|
||||
mass = 1.75f;
|
||||
health = 130;
|
||||
weapons.add(new Weapon("chain-blaster"){{
|
||||
reload = 28f;
|
||||
reload = 14f;
|
||||
x = 4f;
|
||||
alternate = true;
|
||||
ejectEffect = Fx.shellEjectSmall;
|
||||
|
@ -67,7 +67,11 @@ abstract class WeaponsComp implements Teamc, Posc, Rotc{
|
||||
float axisX = this.x + Angles.trnsx(rotation, axisXOffset, weapon.y),
|
||||
axisY = this.y + Angles.trnsy(rotation, axisXOffset, weapon.y);
|
||||
|
||||
mount.rotation = Angles.moveToward(mount.rotation, Angles.angle(axisX, axisY, mount.aimX, mount.aimY) - rotation(), weapon.rotateSpeed);
|
||||
mount.targetRotation = Angles.angle(axisX, axisY, mount.aimX, mount.aimY) - rotation();
|
||||
mount.rotation = Angles.moveToward(mount.rotation, mount.targetRotation, weapon.rotateSpeed);
|
||||
}else{
|
||||
mount.rotation = this.rotation;
|
||||
mount.targetRotation = angleTo(mount.aimX, mount.aimY);
|
||||
}
|
||||
|
||||
if(mount.shoot){
|
||||
@ -75,17 +79,17 @@ abstract class WeaponsComp implements Teamc, Posc, Rotc{
|
||||
|
||||
//shoot if applicable
|
||||
//TODO only shoot if angle is reached, don't shoot inaccurately
|
||||
if(mount.reload <= 0.0001f){
|
||||
if(mount.reload <= 0.0001f && Angles.within(mount.rotation, mount.targetRotation, 1.5f)){
|
||||
for(int i : (weapon.mirror && !weapon.alternate ? Mathf.signs : Mathf.one)){
|
||||
i *= Mathf.sign(weapon.flipped) * Mathf.sign(mount.side);
|
||||
|
||||
//m a t h
|
||||
float weaponRotation = rotation + (weapon.rotate ? mount.rotation : 0);
|
||||
float mountX = this.x + Angles.trnsx(rotation, weapon.x * i, weapon.y),
|
||||
mountY = this.y + Angles.trnsy(rotation, weapon.x * i, weapon.y);
|
||||
mountY = this.y + Angles.trnsy(rotation, weapon.x * i, weapon.y);
|
||||
float shootX = mountX + Angles.trnsx(weaponRotation, weapon.shootX * i, weapon.shootY),
|
||||
shootY = mountY + Angles.trnsy(weaponRotation, weapon.shootX * i, weapon.shootY);
|
||||
float shootAngle = weapon.rotate ? weaponRotation + 90 : Angles.angle(shootX, shootY, mount.aimX, mount.aimY);
|
||||
shootY = mountY + Angles.trnsy(weaponRotation, weapon.shootX * i, weapon.shootY);
|
||||
float shootAngle = weapon.rotate ? weaponRotation + 90 : Angles.angle(shootX, shootY, mount.aimX, mount.aimY) + (this.rotation - angleTo(mount.aimX, mount.aimY));
|
||||
|
||||
shoot(weapon, shootX, shootY, shootAngle);
|
||||
}
|
||||
|
@ -9,6 +9,8 @@ public class WeaponMount{
|
||||
public float reload;
|
||||
/** rotation relative to the unit this mount is on */
|
||||
public float rotation;
|
||||
/** destination rotation; do not modify! */
|
||||
public float targetRotation;
|
||||
/** aiming position in world coordinates */
|
||||
public float aimX, aimY;
|
||||
/** side that's being shot - only valid for mirrors */
|
||||
|
Reference in New Issue
Block a user