diff --git a/src/Const/TankDefinitions.ts b/src/Const/TankDefinitions.ts index 884536d7..afbb2e74 100644 --- a/src/Const/TankDefinitions.ts +++ b/src/Const/TankDefinitions.ts @@ -54,12 +54,14 @@ export interface BulletDefinition { scatterRate: number; /** Used to calculate the life length of a bullet that the barrel shoots. */ lifeLength: number; - /** Knockback factor field of the bullet */ + /** Knockback factor field of the bullet. */ absorbtionFactor: number; /** Projectile color - by default this is set to parent's body color. */ color?: Color; /** Overrides number of sides for projectile. */ sides?: number; + /** Used to calculate the initial burst of speed of the bullet that the barrel shoots. */ + launchSpeed?: number; } /** @@ -70,7 +72,7 @@ export interface BarrelDefinition { angle: number; /** The x offset of the barrel (think of Twin's barrels for example) at base radius (50). */ 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.*/ + /** 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; /** The size of the barrel. Think of Sniper, the longer side is the size. */ size: number; @@ -96,6 +98,10 @@ export interface BarrelDefinition { forceFire?: boolean; /** Barrel color - by default this is set to the 'Barrel' color id. */ color?: Color; + /** The amount of bullets that are shot from the barrel. */ + bulletsPerShot?: number; + /** Whether or not the barrel shoots with right click or with left click. */ + rightClickFire?: boolean; /** The definition of the bullet that is shot from the barrel. */ bullet: BulletDefinition; } diff --git a/src/Entity/Tank/Addons.ts b/src/Entity/Tank/Addons.ts index 618494fa..8966a1b5 100644 --- a/src/Entity/Tank/Addons.ts +++ b/src/Entity/Tank/Addons.ts @@ -340,6 +340,7 @@ class PronouncedDomAddon extends Addon { pronounce.physicsData.values.sides = 2; } } + /** Weird spike addon. Based on the arrasio Original. */ class WeirdSpikeAddon extends Addon { public constructor(owner: BarrelBase) { diff --git a/src/Entity/Tank/Barrel.ts b/src/Entity/Tank/Barrel.ts index 62ee18fa..a70370ad 100644 --- a/src/Entity/Tank/Barrel.ts +++ b/src/Entity/Tank/Barrel.ts @@ -73,8 +73,14 @@ export class ShootCycle { } if (this.pos >= reloadTime * (1 + this.barrelEntity.definition.delay)) { + const bulletCount = this.barrelEntity.definition.bulletsPerShot ?? 1; this.barrelEntity.barrelData.reloadTime = reloadTime; this.barrelEntity.shoot(); + if(bulletCount > 1) { + for (let i = 0; i < bulletCount-1; ++i) { + this.barrelEntity.shoot(false); + } + } this.pos = reloadTime * this.barrelEntity.definition.delay; } @@ -143,8 +149,8 @@ export default class Barrel extends ObjectEntity { } /** Shoots a bullet from the barrel. */ - public shoot() { - this.barrelData.flags ^= BarrelFlags.hasShot; + public shoot(hasShot = true) { + if(hasShot) this.barrelData.flags ^= BarrelFlags.hasShot; // No this is not correct const scatterAngle = (Math.PI / 180) * this.definition.bullet.scatterRate * (Math.random() - .5) * 10; @@ -213,7 +219,6 @@ export default class Barrel extends ObjectEntity { public calculateStatData() { const reloadTime = this.tank.reloadTime * this.definition.reload; - if (reloadTime !== this.shootCycle.reloadTime) { this.shootCycle.pos *= reloadTime / this.shootCycle.reloadTime; this.shootCycle.reloadTime = this.barrelData.reloadTime = reloadTime; @@ -226,7 +231,7 @@ export default class Barrel extends ObjectEntity { this.relationsData.values.team = this.tank.relationsData.values.team; if (!this.tank.rootParent.deletionAnimation){ - this.attemptingShot = this.tank.inputs.attemptingShot(); + this.attemptingShot = this.definition.rightClickFire ? this.tank.inputs.attemptingRepel() : this.tank.inputs.attemptingShot(); this.shootCycle.tick(); } diff --git a/src/Entity/Tank/Projectile/Bullet.ts b/src/Entity/Tank/Projectile/Bullet.ts index 463ac306..5f9f6d52 100644 --- a/src/Entity/Tank/Projectile/Bullet.ts +++ b/src/Entity/Tank/Projectile/Bullet.ts @@ -86,7 +86,7 @@ export default class Bullet extends LivingEntity { this.physicsData.values.pushFactor = ((7 / 3) + bulletDamage) * bulletDefinition.damage * bulletDefinition.absorbtionFactor; this.baseAccel = barrel.bulletAccel; - this.baseSpeed = barrel.bulletAccel + 30 - Math.random() * bulletDefinition.scatterRate; + this.baseSpeed = barrel.bulletAccel + (30 - Math.random() * bulletDefinition.scatterRate) * (bulletDefinition.launchSpeed ?? 1); this.healthData.values.health = this.healthData.values.maxHealth = (1.5 * bulletPenetration + 2) * bulletDefinition.health; this.damagePerTick = (7 + bulletDamage * 3) * bulletDefinition.damage; diff --git a/src/util.ts b/src/util.ts index 03a19e64..b05ef015 100644 --- a/src/util.ts +++ b/src/util.ts @@ -123,3 +123,10 @@ export const saveToLog = (title: string, description: string, color: number) => export const saveToVLog = (text: string) => { if (doVerboseLogs) console.log("[v] " + text); } + +/** + * Returns a value inbetween 2 seperate numbers + */ +export const randomRange = (min: number, max: number): number => { + return min + ((max - min) * Math.random()); +}