Skip to content

Commit

Permalink
Tuning
Browse files Browse the repository at this point in the history
  • Loading branch information
solcloud committed Apr 1, 2023
1 parent 6e6954e commit 4098545
Show file tree
Hide file tree
Showing 24 changed files with 180 additions and 188 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ open http://localhost:9000

### Server

Currently, there is no official public server available (as match making service is also WIP), but you can run server locally (or somebody can host it for you).
Currently, there is no official public server available (as match making service is also WIP), but you can run server yourself (or somebody can host it for you).

```bash
composer install -a --no-dev
Expand Down
3 changes: 1 addition & 2 deletions cli/adBot.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
$address = "udp://localhost:$port";
/////

$factory = new Factory();
$socket = $factory->createClient($address, 4);
$socket = (new Factory())->createClient($address, 4);
$socket->write('login ' . $loginCode);

$bool = true;
Expand Down
3 changes: 1 addition & 2 deletions cli/bot.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
$address = "udp://localhost:$port";
/////

$factory = new Factory();
$socket = $factory->createClient($address, 4);
$socket = (new Factory())->createClient($address, 4);
$socket->write('login ' . $loginCode);

$commandPool = [
Expand Down
3 changes: 1 addition & 2 deletions cli/client.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
$address = "udp://localhost:$port";
/////

$factory = new Factory();
$socket = $factory->createClient($address, 4);
$socket = (new Factory())->createClient($address, 4);

$socket->write('login ' . $loginCode);
if ($command === 'afk') {
Expand Down
3 changes: 1 addition & 2 deletions cli/udp-ws-bridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
///
$portWs = (int)($argv[1] ?? 8081);
$portUdp = (int)($argv[2] ?? 8080);
$addressUdp = "udp://localhost:{$portUdp}";
///

$addressUdp = "udp://localhost:{$portUdp}";
$udp = (new Factory())->createClient($addressUdp, 4);

$ws = new Server([
'filter' => ['text'],
'fragment_size' => '8192',
Expand Down
4 changes: 2 additions & 2 deletions electron/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const path = require('path')
app.whenReady().then(() => {
const win = new BrowserWindow({
autoHideMenuBar: true,
width: 800,
height: 600,
width: 1200,
height: 900,
webPreferences: {
devTools: false,
nodeIntegration: false,
Expand Down
12 changes: 6 additions & 6 deletions server/src/Core/Box.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ public function getBase(): Point
public function toArray(): array
{
return [
"width" => $this->widthX,
"height" => $this->heightY,
"depth" => $this->depthZ,
"x" => $this->lowerLeftPoint->x,
"y" => $this->lowerLeftPoint->y,
"z" => $this->lowerLeftPoint->z,
'width' => $this->widthX,
'height' => $this->heightY,
'depth' => $this->depthZ,
'x' => $this->lowerLeftPoint->x,
'y' => $this->lowerLeftPoint->y,
'z' => $this->lowerLeftPoint->z,
];
}

Expand Down
40 changes: 20 additions & 20 deletions server/src/Core/Player.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ final class Player
private int $eventIdShotSlowdown = 3;
private int $eventIdMovement = 4;
private int $eventIdGravity = 5;
private int $eventIdOther = 6; // last
private int $eventIdLast = 6; // last

public function __construct(
private int $id,
Expand Down Expand Up @@ -76,7 +76,7 @@ public function onTick(int $tick): void
$this->setActiveFloor(null);
}

for ($i = 0; $i <= $this->eventIdOther; $i++) {
for ($i = 0; $i <= $this->eventIdLast; $i++) {
if (!isset($this->events[$i])) {
continue;
}
Expand Down Expand Up @@ -292,24 +292,24 @@ public function serialize(): array
}

return [
"id" => $this->id,
"color" => $this->color->value,
"money" => $this->inventory->getDollars(),
"item" => $equippedItem->toArrayCache,
"canAttack" => $this->world->canAttack($this),
"canBuy" => $this->world->canBuy($this),
"canPlant" => $this->world->canPlant($this),
"slots" => $this->inventory->getFilledSlots(),
"health" => $this->health,
"position" => $this->position->toArray(),
"look" => $this->sight->toArray(),
"isAttacker" => $this->isPlayingOnAttackerSide,
"sight" => $this->getSightHeight(),
"armor" => $this->getArmorValue(),
"armorType" => $this->getArmorType()->value,
"ammo" => $ammo,
"ammoReserve" => $ammoReserve,
"isReloading" => $reloading,
'id' => $this->id,
'color' => $this->color->value,
'money' => $this->inventory->getDollars(),
'item' => $equippedItem->toArrayCache,
'canAttack' => $this->world->canAttack($this),
'canBuy' => $this->world->canBuy($this),
'canPlant' => $this->world->canPlant($this),
'slots' => $this->inventory->getFilledSlots(),
'health' => $this->health,
'position' => $this->position->toArray(),
'look' => $this->sight->toArray(),
'isAttacker' => $this->isPlayingOnAttackerSide,
'sight' => $this->getSightHeight(),
'armor' => $this->getArmorValue(),
'armorType' => $this->getArmorType()->value,
'ammo' => $ammo,
'ammoReserve' => $ammoReserve,
'isReloading' => $reloading,
];
}

Expand Down
4 changes: 2 additions & 2 deletions server/src/Core/PlayerCamera.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public function getRotationVertical(): float
public function toArray()
{
return [
"horizontal" => $this->getRotationHorizontal(),
"vertical" => $this->getRotationVertical(),
'horizontal' => $this->getRotationHorizontal(),
'vertical' => $this->getRotationVertical(),
];
}

Expand Down
2 changes: 1 addition & 1 deletion server/src/Core/World.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class World
public function __construct(private Game $game)
{
$this->playerPotentialDistanceSquared = ($game->getBacktrack()->numberOfHistoryStates + 2) * pow(Setting::moveDistancePerTick(), 2)
+ pow(Setting::playerBoundingRadius(), 2); // fixme: more tests to know if it is reliable heuristic value
+ pow(Setting::playerBoundingRadius(), 2); // fixme: more tests to know if it is reliable heuristic value, also test with further backtrack
}

public function roundReset(): void
Expand Down
3 changes: 1 addition & 2 deletions server/src/Net/ClueSocket.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ class ClueSocket implements NetConnector
public function __construct(string $bindAddress)
{
try {
$factory = new Factory();
$this->socket = $factory->createServer($bindAddress);
$this->socket = (new Factory())->createServer($bindAddress);
$this->resource = $this->socket->getResource(); // @phpstan-ignore-line
} catch (Exception $ex) {
throw new NetException($ex->getMessage(), $ex->getCode(), $ex);
Expand Down
2 changes: 1 addition & 1 deletion server/src/Weapon/RifleM4A4.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class RifleM4A4 extends AmmoBasedWeapon
public const armorPenetration = 67;
public const recoilResetMs = 310;
public const recoilPattern = [
[0, 0], // fixme
[0, 0], // fixme better pattern
[+0.09, +0.17],
[-0.02, +0.72],
[+0.04, +1.53],
Expand Down
5 changes: 0 additions & 5 deletions www/.htaccess

This file was deleted.

18 changes: 9 additions & 9 deletions www/assets/js/PlayerAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export class PlayerAction {

resetStates() {
this.#states = {
attacklook: '',
lastlook: '',
attackLook: '',
lastLook: '',
sprayTriggerStartMs: null,
moveForward: false,
moveBackward: false,
Expand Down Expand Up @@ -53,13 +53,13 @@ export class PlayerAction {
this.actionCallback[Action.SCORE_BOARD] = (enabled) => hud.toggleScore(enabled)
}

#rotationToServerlook(xy) {
#rotationToServerLook(xy) {
return `look ${xy[0].toFixed(2)} ${xy[1].toFixed(2)}`
}

attack(xy) {
this.#states.attack = true
this.#states.attacklook = this.#rotationToServerlook(xy)
this.#states.attackLook = this.#rotationToServerLook(xy)
}

attack2() {
Expand Down Expand Up @@ -151,17 +151,17 @@ export class PlayerAction {
this.#states.attack2 = false
}
if (this.#states.attack) {
action.push(this.#states.attacklook)
action.push(this.#states.attackLook)
action.push('attack')
this.#states.attack = false
} else if (this.#states.spraying && this.#states.sprayTriggerStartMs && this.#states.sprayTriggerStartMs + sprayTriggerDeltaMs < Date.now()) {
action.push(this.#rotationToServerlook(game.getPlayerMeRotation()))
action.push(this.#rotationToServerLook(game.getPlayerMeRotation()))
action.push('attack')
} else {
let look = this.#rotationToServerlook(game.getPlayerMeRotation())
if (this.#states.lastlook !== look) {
let look = this.#rotationToServerLook(game.getPlayerMeRotation())
if (this.#states.lastLook !== look) {
action.push(look)
this.#states.lastlook = look
this.#states.lastLook = look
}
}

Expand Down
1 change: 0 additions & 1 deletion www/assets/threejs/GLTFLoader.js

This file was deleted.

1 change: 0 additions & 1 deletion www/assets/threejs/RGBELoader.js

This file was deleted.

1 change: 0 additions & 1 deletion www/assets/threejs/SkeletonUtils.js

This file was deleted.

Loading

0 comments on commit 4098545

Please sign in to comment.