diff --git a/src/Const/TankDefinitions.json b/src/Const/TankDefinitions.json index 5350f193..0d0208cd 100644 --- a/src/Const/TankDefinitions.json +++ b/src/Const/TankDefinitions.json @@ -3820,6 +3820,7 @@ "angle": 0, "offset": 0, "size": 110, + "bulletSpawnDistance": 110, "width": 42, "delay": 0, "reload": 3, @@ -3842,6 +3843,7 @@ "angle": 0, "offset": 0, "size": 95, + "bulletSpawnDistance": 110, "width": 56.7, "delay": 0.2, "reload": 3, @@ -3864,6 +3866,7 @@ "angle": 0, "offset": 0, "size": 80, + "bulletSpawnDistance": 110, "width": 71.39999999999999, "delay": 0.4, "reload": 3, diff --git a/src/Const/TankDefinitions.ts b/src/Const/TankDefinitions.ts index 884536d7..aaf2d379 100644 --- a/src/Const/TankDefinitions.ts +++ b/src/Const/TankDefinitions.ts @@ -72,6 +72,8 @@ export interface BarrelDefinition { offset: number; /** The y offset of the barrel (distance from the tanks main body) at base radius (50). Will have no effect on clientside tankrendering.*/ distance?: number; + /** Overrides the distance from tank center at which bullets spawned by this barrel appear. Defaults to `size` if not set. */ + bulletSpawnDistance?: number; /** The size of the barrel. Think of Sniper, the longer side is the size. */ size: number; /** The width of the barrel. Think of Sniper, the shorter side is the width. Width is used to determine bullet size */ diff --git a/src/Entity/Tank/Projectile/Bullet.ts b/src/Entity/Tank/Projectile/Bullet.ts index 92460611..045850b9 100644 --- a/src/Entity/Tank/Projectile/Bullet.ts +++ b/src/Entity/Tank/Projectile/Bullet.ts @@ -96,9 +96,10 @@ export default class Bullet extends LivingEntity { this.lifeLength = bulletDefinition.lifeLength * 75; const {x, y} = tank.getWorldPosition(); + const bulletSpawnDistance = (barrel.definition.bulletSpawnDistance ?? barrel.definition.size) * scaleFactor; - this.positionData.values.x = x + (Math.cos(shootAngle) * barrel.physicsData.values.size) - Math.sin(shootAngle) * barrel.definition.offset * scaleFactor + Math.cos(shootAngle) * (barrel.definition.distance || 0); - this.positionData.values.y = y + (Math.sin(shootAngle) * barrel.physicsData.values.size) + Math.cos(shootAngle) * barrel.definition.offset * scaleFactor + Math.sin(shootAngle) * (barrel.definition.distance || 0); + this.positionData.values.x = x + (Math.cos(shootAngle) * bulletSpawnDistance) - Math.sin(shootAngle) * barrel.definition.offset * scaleFactor + Math.cos(shootAngle) * ((barrel.definition.distance ?? 0) * scaleFactor); + this.positionData.values.y = y + (Math.sin(shootAngle) * bulletSpawnDistance) + Math.cos(shootAngle) * barrel.definition.offset * scaleFactor + Math.sin(shootAngle) * ((barrel.definition.distance ?? 0) * scaleFactor); this.positionData.values.angle = shootAngle; }