From 5cb05dbd0a5bef2fce07294a23136c13790ee330 Mon Sep 17 00:00:00 2001 From: Daniel Maixner Date: Sat, 22 Oct 2022 22:24:55 +0200 Subject: [PATCH] Tuning --- server/src/Weapon/AmmoBasedWeapon.php | 3 ++- server/src/Weapon/PistolGlock.php | 2 +- server/src/Weapon/PistolP250.php | 2 +- server/src/Weapon/PistolUsp.php | 2 +- server/src/Weapon/RifleAk.php | 2 +- server/src/Weapon/RifleM4A4.php | 2 +- test/og/Shooting/PlayerKillTest.php | 13 ++++++++++--- 7 files changed, 17 insertions(+), 9 deletions(-) diff --git a/server/src/Weapon/AmmoBasedWeapon.php b/server/src/Weapon/AmmoBasedWeapon.php index d93c1cb..d35a84a 100644 --- a/server/src/Weapon/AmmoBasedWeapon.php +++ b/server/src/Weapon/AmmoBasedWeapon.php @@ -37,9 +37,10 @@ public function unEquip(): void public function reset(): void { - $this->reloading = false; $this->ammo = static::magazineCapacity; $this->ammoReserve = static::reserveAmmo; + $this->reloading = false; + $this->lastAttackTick = 0; } public function canAttack(int $tickId): bool diff --git a/server/src/Weapon/PistolGlock.php b/server/src/Weapon/PistolGlock.php index 03b9591..cdd84c9 100644 --- a/server/src/Weapon/PistolGlock.php +++ b/server/src/Weapon/PistolGlock.php @@ -13,7 +13,7 @@ final class PistolGlock extends AmmoBasedWeapon public const magazineCapacity = 12; public const reserveAmmo = 120; public const killAward = 300; - public const fireRateMs = 35; + public const fireRateMs = 150; public const damage = 61; public const range = 5123; diff --git a/server/src/Weapon/PistolP250.php b/server/src/Weapon/PistolP250.php index 385455b..cbac122 100644 --- a/server/src/Weapon/PistolP250.php +++ b/server/src/Weapon/PistolP250.php @@ -13,7 +13,7 @@ final class PistolP250 extends AmmoBasedWeapon public const magazineCapacity = 13; public const reserveAmmo = 26; public const killAward = 300; - public const fireRateMs = 35; + public const fireRateMs = 150; public const damage = 61; public const range = 5123; diff --git a/server/src/Weapon/PistolUsp.php b/server/src/Weapon/PistolUsp.php index e21819d..54b9df2 100644 --- a/server/src/Weapon/PistolUsp.php +++ b/server/src/Weapon/PistolUsp.php @@ -13,7 +13,7 @@ final class PistolUsp extends AmmoBasedWeapon public const magazineCapacity = 12; public const reserveAmmo = 24; public const killAward = 300; - public const fireRateMs = 10; + public const fireRateMs = 170; public const damage = 116; public const range = 5123; diff --git a/server/src/Weapon/RifleAk.php b/server/src/Weapon/RifleAk.php index 8b2dc83..f1e4357 100644 --- a/server/src/Weapon/RifleAk.php +++ b/server/src/Weapon/RifleAk.php @@ -14,7 +14,7 @@ final class RifleAk extends AmmoBasedWeapon public const reserveAmmo = 90; public const killAward = 300; public const runningSpeed = 215; - public const fireRateMs = 10; + public const fireRateMs = 100; public const damage = 36; public const armorPenetration = 77; public const range = 250123; diff --git a/server/src/Weapon/RifleM4A4.php b/server/src/Weapon/RifleM4A4.php index bd58b2f..33e2037 100644 --- a/server/src/Weapon/RifleM4A4.php +++ b/server/src/Weapon/RifleM4A4.php @@ -14,7 +14,7 @@ final class RifleM4A4 extends AmmoBasedWeapon public const reserveAmmo = 90; public const killAward = 300; public const runningSpeed = 215; - public const fireRateMs = 12; + public const fireRateMs = 90; public const damage = 33; public const armorPenetration = 67; public const range = 150123; diff --git a/test/og/Shooting/PlayerKillTest.php b/test/og/Shooting/PlayerKillTest.php index 58d895b..c61db6c 100644 --- a/test/og/Shooting/PlayerKillTest.php +++ b/test/og/Shooting/PlayerKillTest.php @@ -8,6 +8,7 @@ use cs\Core\Player; use cs\Core\Point; use cs\Core\Setting; +use cs\Core\Util; use cs\Core\Wall; use cs\Enum\ArmorType; use cs\Enum\BuyMenuItem; @@ -124,19 +125,25 @@ public function testUspKillPlayerInThreeBulletsInChestWithNoKevlar(): void $this->assertTrue($player2->isAlive()); $tickId = $game->getTickId(); - $game->tick(++$tickId); + for ($i = 1; $i <= Util::millisecondsToFrames(PistolUsp::fireRateMs); $i++) { + $game->tick(++$tickId); + } $this->assertNotNull($player2->attack()); $this->assertTrue($player1->isAlive()); $this->assertTrue($player2->isAlive()); $this->assertSame(1, $game->getRoundNumber()); - $game->tick(++$tickId); + for ($i = 1; $i <= Util::millisecondsToFrames(PistolUsp::fireRateMs); $i++) { + $game->tick(++$tickId); + } $this->assertNotNull($player2->attack()); $this->assertFalse($player1->isAlive()); $this->assertTrue($player2->isAlive()); $this->assertSame(1, $game->getRoundNumber()); - $game->tick(++$tickId); + for ($i = 1; $i <= Util::millisecondsToFrames(PistolUsp::fireRateMs); $i++) { + $game->tick(++$tickId); + } $this->assertFalse($game->getScore()->attackersIsWinning()); $this->assertSame(0, $game->getScore()->getScoreAttackers()); $this->assertSame(1, $game->getScore()->getScoreDefenders());