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
10 changes: 8 additions & 2 deletions src/Const/TankDefinitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand All @@ -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;
Expand All @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions src/Entity/Tank/Addons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
13 changes: 9 additions & 4 deletions src/Entity/Tank/Barrel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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();
}

Expand Down
2 changes: 1 addition & 1 deletion src/Entity/Tank/Projectile/Bullet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}