survivors: adding pull range upgrade

renaming dagger to chain ball
increasing returning speed for chain ball
This commit is contained in:
Sheldan
2025-09-07 15:06:40 +02:00
parent 33310100f7
commit 70130f47a4
4 changed files with 28 additions and 11 deletions

View File

@@ -1,7 +1,7 @@
import type {ChanceEntry, Item} from "./interfaces.ts"; import type {ChanceEntry, Item} from "./interfaces.ts";
import {Player} from "./Player.ts"; import {Player} from "./Player.ts";
import {randomItem} from "./utils.ts"; import {randomItem} from "./utils.ts";
import {Dagger, HomingPistol, Pistol, SpreadWeapon} from "./weapons.ts"; import {ChainBall, HomingPistol, Pistol, SpreadWeapon} from "./weapons.ts";
import type {World} from "./World.ts"; import type {World} from "./World.ts";
export enum Rarity { export enum Rarity {
@@ -40,7 +40,8 @@ export class ItemManagement {
this.ITEMS.push(new HomingPistolItem()) this.ITEMS.push(new HomingPistolItem())
this.ITEMS.push(new PistolItem()) this.ITEMS.push(new PistolItem())
this.ITEMS.push(new SpreadWeaponItem()) this.ITEMS.push(new SpreadWeaponItem())
this.ITEMS.push(new DaggerWeaponItem()) this.ITEMS.push(new ChainBallWeaponItem())
this.ITEMS.push(new PullRangeUp())
} }
} }
@@ -96,6 +97,21 @@ export class SpeedUp extends BaseItem {
} }
} }
export class PullRangeUp extends BaseItem {
pickup(player: Player, world: World) {
player.stats.pullRange *= 1.1
super.pickup(player, world)
}
name() {
return 'pull range'
}
getRarity(): Rarity {
return Rarity.COMMON;
}
}
export class HealthUp extends BaseItem { export class HealthUp extends BaseItem {
pickup(player: Player, world: World) { pickup(player: Player, world: World) {
player.stats.health += 1 player.stats.health += 1
@@ -156,14 +172,14 @@ export class SpreadWeaponItem extends BaseItem {
} }
} }
export class DaggerWeaponItem extends BaseItem { export class ChainBallWeaponItem extends BaseItem {
pickup(player: Player, world: World) { pickup(player: Player, world: World) {
player.addWeapon(Dagger.createDagger(world)) player.addWeapon(ChainBall.createChainBall(world))
super.pickup(player, world) super.pickup(player, world)
} }
name() { name() {
return 'dagger' return 'chain ball'
} }
getRarity(): Rarity { getRarity(): Rarity {

View File

@@ -167,6 +167,7 @@ export class WeaponProjectile extends Projectile {
this.position = straightMove(this.position, this.speedVec) this.position = straightMove(this.position, this.speedVec)
if(this.position.distanceTo(this.target) < this.stats.size) { if(this.position.distanceTo(this.target) < this.stats.size) {
this.movingBack = true; this.movingBack = true;
this.speedVec = this.speedVec.multiply(3)
} }
} else { } else {
this.position = moveInDirectionOf(this.position, this.world.player.position, this.speedVec.vecLength()) this.position = moveInDirectionOf(this.position, this.world.player.position, this.speedVec.vecLength())

View File

@@ -31,9 +31,9 @@ export class PlayerInfo implements DrawContainer {
this.statLabels = [ this.statLabels = [
new StatLabel(() => 'Money', () => this.world.player.status.wealth), new StatLabel(() => 'Money', () => this.world.player.status.wealth),
new StatLabel(() => 'Level', () => this.world.player.status.level), new StatLabel(() => 'Level', () => this.world.player.status.level),
new StatLabel(() => 'Speed', () => this.world.player.stats.speed), new StatLabel(() => 'Speed', () => Math.floor(this.world.player.stats.speed)),
new StatLabel(() => 'Pull range', () => this.world.player.stats.pullRange), new StatLabel(() => 'Pull range', () => Math.floor(this.world.player.stats.pullRange)),
new StatLabel(() => 'Weapon range', () => this.world.player.stats.effectiveWeaponRange) new StatLabel(() => 'Weapon range', () => Math.floor(this.world.player.stats.effectiveWeaponRange))
] ]
} }

View File

@@ -93,7 +93,7 @@ export abstract class MeleeWeapon extends RangeWeapon {
this.shootCooldown = 0 this.shootCooldown = 0
} }
} }
export class Dagger extends MeleeWeapon { export class ChainBall extends MeleeWeapon {
createProjectile(): boolean { createProjectile(): boolean {
let range = this.calculateRange() let range = this.calculateRange()
@@ -112,7 +112,7 @@ export class Dagger extends MeleeWeapon {
} }
} }
static createDagger(world: World, offset?: Vector) { static createChainBall(world: World, offset?: Vector) {
if(!offset) { if(!offset) {
offset = new Vector(5, 5) offset = new Vector(5, 5)
} }
@@ -120,7 +120,7 @@ export class Dagger extends MeleeWeapon {
.withProjectileSpeed(3) .withProjectileSpeed(3)
.withDamage(15) .withDamage(15)
.withShootInterval(50) .withShootInterval(50)
let pistol = new Dagger(world, stats) let pistol = new ChainBall(world, stats)
pistol.offset = offset; pistol.offset = offset;
pistol.size = 4; pistol.size = 4;
pistol.color = 'gray'; pistol.color = 'gray';