From d7468543074d715268e7c2c5e70ebf275366a5ba Mon Sep 17 00:00:00 2001 From: schmelczerandras Date: Tue, 27 Oct 2020 15:01:56 +0100 Subject: [PATCH] Tweak settings & fix bug --- backend/package.json | 2 +- backend/src/default-options.ts | 4 ++-- backend/src/game-server.ts | 5 ++++- backend/src/objects/player-character-physical.ts | 11 +++++------ shared/src/settings.ts | 6 +++--- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/backend/package.json b/backend/package.json index a1a2462..4b0be84 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "declared-server", - "version": "0.0.8", + "version": "0.0.11", "description": "Game server for decla.red", "keywords": [], "author": "AndrĂ¡s Schmelczer (https://schmelczer.dev/)", diff --git a/backend/src/default-options.ts b/backend/src/default-options.ts index c08d4f7..9981362 100644 --- a/backend/src/default-options.ts +++ b/backend/src/default-options.ts @@ -4,8 +4,8 @@ export const defaultOptions: Options = { port: 3000, name: 'Test server', playerLimit: 16, - npcCount: 8, - seed: 0, + npcCount: 6, + seed: Math.random(), scoreLimit: 500, worldSize: 8000, }; diff --git a/backend/src/game-server.ts b/backend/src/game-server.ts index 16ab0de..b1ad947 100644 --- a/backend/src/game-server.ts +++ b/backend/src/game-server.ts @@ -12,6 +12,7 @@ import { GameEnd, GameStart, Command, + last, } from 'shared'; import { createWorld } from './map/create-world'; import { DeltaTimeCalculator } from './helper/delta-time-calculator'; @@ -137,7 +138,9 @@ export class GameServer { console.log( `Median physics time: ${this.deltaTimes[ Math.floor(framesBetweenDeltaTimeCalculation / 2) - ].toFixed(2)} ms`, + ].toFixed(2)} ms\n`, + 'Tail times: ', + this.deltaTimes.slice(-20).map((v) => `${v.toFixed(2)} ms`), ); console.log( `Memory used: ${(process.memoryUsage().rss / 1024 / 1024).toFixed(2)} MB`, diff --git a/backend/src/objects/player-character-physical.ts b/backend/src/objects/player-character-physical.ts index 54d7d7b..6da64bb 100644 --- a/backend/src/objects/player-character-physical.ts +++ b/backend/src/objects/player-character-physical.ts @@ -96,7 +96,6 @@ export class PlayerCharacterPhysical startPosition: vec2, ) { super(id(), name, killCount, deathCount, team, settings.playerMaxHealth); - this.head = new CirclePhysical( vec2.add(vec2.create(), startPosition, PlayerCharacterPhysical.headOffset), PlayerCharacterPhysical.headRadius, @@ -149,7 +148,7 @@ export class PlayerCharacterPhysical other.destroy(); this.health -= other.strength; this.remoteCall('setHealth', this.health); - if (this.health <= 0) { + if (this.health <= 0 && this.isAlive) { this.kill(); other.originator.addKill(); } @@ -352,14 +351,14 @@ export class PlayerCharacterPhysical center, PlayerCharacterPhysical.leftFootOffset, deltaTime, - 15000, + 150, ); this.springMove( this.rightFoot, center, PlayerCharacterPhysical.rightFootOffset, deltaTime, - 15000, + 150, ); this.springMove( @@ -367,7 +366,7 @@ export class PlayerCharacterPhysical center, PlayerCharacterPhysical.headOffset, deltaTime, - 25000, + 350, ); } @@ -387,7 +386,7 @@ export class PlayerCharacterPhysical vec2.scale( positionDelta, positionDeltaDirection, - positionDeltaLength * deltaTime * strength, + positionDeltaLength ** 2 * deltaTime * strength, ); object.applyForce(positionDelta, deltaTime); diff --git a/shared/src/settings.ts b/shared/src/settings.ts index 8270ec8..d70b23f 100644 --- a/shared/src/settings.ts +++ b/shared/src/settings.ts @@ -25,10 +25,10 @@ export const settings = { planetPointGenerationInterval: 1.5, planetPointGenerationValue: 1, maxGravityDistance: 800, - maxGravityQ: 10000, + maxGravityQ: 5000, planetControlThreshold: 0.2, playerMaxHealth: 100, - maxGravityStrength: 20000, + maxGravityStrength: 10000, maxAcceleration: 60000, playerMaxStrength: 80, endGameDeltaScaling: 4, @@ -111,7 +111,7 @@ export const settings = { }, palette: [declaColor, neutralColor, redColor], paletteDim: [declaColorDim, neutralColor, redColorDim], - targetPhysicsDeltaTimeInMilliseconds: 20, + targetPhysicsDeltaTimeInMilliseconds: 15, minPhysicsSleepTime: 4, inViewAreaSize: 1920 * 1080 * 3, };