Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Const/TankDefinitions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3820,6 +3820,7 @@
"angle": 0,
"offset": 0,
"size": 110,
"bulletSpawnDistance": 110,
"width": 42,
"delay": 0,
"reload": 3,
Expand All @@ -3842,6 +3843,7 @@
"angle": 0,
"offset": 0,
"size": 95,
"bulletSpawnDistance": 110,
"width": 56.7,
"delay": 0.2,
"reload": 3,
Expand All @@ -3864,6 +3866,7 @@
"angle": 0,
"offset": 0,
"size": 80,
"bulletSpawnDistance": 110,
"width": 71.39999999999999,
"delay": 0.4,
"reload": 3,
Expand Down
2 changes: 2 additions & 0 deletions src/Const/TankDefinitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
5 changes: 3 additions & 2 deletions src/Entity/Tank/Projectile/Bullet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down