Skip to content

Commit

Permalink
Fix gun balance (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
beverly-hills-money-gangster authored Aug 17, 2024
1 parent 39d10f6 commit 02046e7
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Game server can be configured using the following environment variables:
- `GAME_SERVER_MOVES_UPDATE_FREQUENCY_MLS` Frequency(in milliseconds) at which server notifies players about other players' positioning on the map. Default - `50`.
- `GAME_SERVER_MAX_IDLE_TIME_MLS` Maximum idle time(in milliseconds) for a player. "Idle" - no network activity, which includes in-game events + ping responds. For example, if player connects to a game and doesn't move but responds to PING requests, then it's NOT considered idle. This check is mostly needed when a TCP connection was closed abruptly(no FIN). Default - `10_000`.
- `GAME_SERVER_DEFAULT_SHOTGUN_DAMAGE` Gunshot damage. Default - `20`.
- `GAME_SERVER_DEFAULT_RAILGUN_DAMAGE` Railgun damage. Default - `100`.
- `GAME_SERVER_DEFAULT_RAILGUN_DAMAGE` Railgun damage. Default - `75`.
- `GAME_SERVER_DEFAULT_PUNCH_DAMAGE` Punch damage. Default - `50`.
- `GAME_SERVER_PIN_CODE` Server access pin code(digits only, no less than 4). Used in HMAC that is appended to every message. Default - `5555`.
- `GAME_SERVER_FAST_TCP` Enables fast TCP configurations(used mostly for testing, not recommended to be set to `false` in prod). Default - `true`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@
@Component
public class AntiCheat {


private static final Map<AttackType, Double> MAX_ATTACK_DISTANCE = Map.of(
AttackType.PUNCH, 1.2,
AttackType.SHOTGUN, 5.5,
AttackType.RAILGUN, 7.5);
AttackType.SHOTGUN, 7.0,
AttackType.RAILGUN, 10.0);

private static final Map<AttackType, Integer> ATTACK_DELAY_MLS = Map.of(
AttackType.PUNCH, 300,
AttackType.SHOTGUN, 450,
AttackType.RAILGUN, 1_500);
AttackType.RAILGUN, 2_000);

public static final List<AttackInfo> ATTACKS_INFO;

Expand Down Expand Up @@ -67,8 +66,8 @@ public boolean isTeleportTooFar(final Vector playerPosition, final Vector telepo
return Vector.getDistance(playerPosition, teleportPosition) > MAX_TELEPORT_DISTANCE;
}

public boolean isTooMuchDistanceTravelled(final double distanceTravelled,
final int periodSec) {
public boolean isTooMuchDistanceTravelled(
final double distanceTravelled, final int periodSec) {
return distanceTravelled > MAX_DISTANCE_TRAVELLED_IN_ONE_SEC * periodSec;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public interface ServerConfig {
System.getenv("GAME_SERVER_DEFAULT_SHOTGUN_DAMAGE"), 20);

int DEFAULT_RAILGUN_DAMAGE = NumberUtils.toInt(
System.getenv("GAME_SERVER_DEFAULT_RAILGUN_DAMAGE"), 100);
System.getenv("GAME_SERVER_DEFAULT_RAILGUN_DAMAGE"), 75);

int DEFAULT_PUNCH_DAMAGE = NumberUtils.toInt(System.getenv("GAME_SERVER_DEFAULT_PUNCH_DAMAGE"),
50);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public class Spawner {
private static final Vector DEFENCE_SPAWN_POSITION
= Vector.builder().x(-24.609121f - 0.35f).y(11.956983f).build();

// + -> right
private static final Vector INVISIBILITY_SPAWN_POSITION
= Vector.builder().x(8.045f).y(18.5f - 0.5f).build();

Expand Down Expand Up @@ -102,6 +101,7 @@ public PlayerState.PlayerCoordinates spawnPlayer(Game game) {
.allPlayers()
.map(PlayerStateChannel::getPlayerState)
.collect(Collectors.toList());
// TODO randomize a little
// get the least populated spawn
var playersAroundSpawn = new TreeMap<Integer, PlayerState.PlayerCoordinates>();
SPAWNS.forEach(spawn -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.SetEnvironmentVariable;

@SetEnvironmentVariable(key = "GAME_SERVER_DEFAULT_RAILGUN_DAMAGE", value = "100")
@SetEnvironmentVariable(key = "GAME_SERVER_POWER_UPS_ENABLED", value = "false")
@SetEnvironmentVariable(key = "GAME_SERVER_TELEPORTS_ENABLED", value = "false")
@SetEnvironmentVariable(key = "GAME_SERVER_MOVES_UPDATE_FREQUENCY_MLS", value = "99999")
Expand Down Expand Up @@ -754,7 +755,6 @@ public void testRailgunKill() throws Exception {
.build());
waitUntilQueueNonEmpty(deadConnection.getResponse());


waitUntilQueueNonEmpty(deadConnection.getResponse());
assertTrue(deadConnection.isConnected(), "Dead players should be connected");
assertTrue(killerConnection.isConnected(), "Killer must be connected");
Expand Down

0 comments on commit 02046e7

Please sign in to comment.