Skip to content

Commit

Permalink
Merge branch 'ParadiseDelta-Items' of https://github.com/Rinary1/spac…
Browse files Browse the repository at this point in the history
…e-sunrise into ParadiseDelta-Items
  • Loading branch information
Rinary1 committed Jun 25, 2024
2 parents 0b73a51 + 6c7231a commit dd9c5a6
Show file tree
Hide file tree
Showing 12 changed files with 134 additions and 26 deletions.
80 changes: 80 additions & 0 deletions Content.IntegrationTests/Tests/Commands/ForceMapTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
using Content.Shared.CCVar;
using Robust.Shared.Configuration;
using Robust.Shared.Console;

namespace Content.IntegrationTests.Tests.Commands;

[TestFixture]
public sealed class ForceMapTest
{
private const string DefaultMapName = "Empty";
private const string BadMapName = "asdf_asd-fa__sdfAsd_f"; // Hopefully no one ever names a map this...
private const string TestMapEligibleName = "ForceMapTestEligible";
private const string TestMapIneligibleName = "ForceMapTestIneligible";

[TestPrototypes]
private static readonly string TestMaps = @$"
- type: gameMap
id: {TestMapIneligibleName}
mapName: {TestMapIneligibleName}
mapPath: /Maps/Test/empty.yml
minPlayers: 20
maxPlayers: 80
stations:
Empty:
stationProto: StandardNanotrasenStation
components:
- type: StationNameSetup
mapNameTemplate: ""Empty""
- type: gameMap
id: {TestMapEligibleName}
mapName: {TestMapEligibleName}
mapPath: /Maps/Test/empty.yml
minPlayers: 0
stations:
Empty:
stationProto: StandardNanotrasenStation
components:
- type: StationNameSetup
mapNameTemplate: ""Empty""
";

[Test]
public async Task TestForceMapCommand()
{
await using var pair = await PoolManager.GetServerClient();
var server = pair.Server;

var entMan = server.EntMan;
var configManager = server.ResolveDependency<IConfigurationManager>();
var consoleHost = server.ResolveDependency<IConsoleHost>();

await server.WaitAssertion(() =>
{
// Make sure we're set to the default map
Assert.That(configManager.GetCVar(CCVars.GameMap), Is.EqualTo(DefaultMapName),
$"Test didn't start on expected map ({DefaultMapName})!");

// Try changing to a map that doesn't exist
consoleHost.ExecuteCommand($"forcemap {BadMapName}");
Assert.That(configManager.GetCVar(CCVars.GameMap), Is.EqualTo(DefaultMapName),
$"Forcemap succeeded with a map that does not exist ({BadMapName})!");

// Try changing to a valid map
consoleHost.ExecuteCommand($"forcemap {TestMapEligibleName}");
Assert.That(configManager.GetCVar(CCVars.GameMap), Is.EqualTo(TestMapEligibleName),
$"Forcemap failed with a valid map ({TestMapEligibleName})");

// Try changing to a map that exists but is ineligible
consoleHost.ExecuteCommand($"forcemap {TestMapIneligibleName}");
Assert.That(configManager.GetCVar(CCVars.GameMap), Is.EqualTo(TestMapIneligibleName),
$"Forcemap failed with valid but ineligible map ({TestMapIneligibleName})!");
});

// Cleanup
configManager.SetCVar(CCVars.GameMap, DefaultMapName);

await pair.CleanReturnAsync();
}
}
2 changes: 1 addition & 1 deletion Content.Server/Connection/GrantConnectBypassCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Content.Server.Connection;

[AdminCommand(AdminFlags.Admin)]
[AdminCommand(AdminFlags.Moderator)]
public sealed class GrantConnectBypassCommand : LocalizedCommands
{
private static readonly TimeSpan DefaultDuration = TimeSpan.FromHours(1);
Expand Down
4 changes: 2 additions & 2 deletions Content.Server/GameTicking/Commands/ForceMapCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public void Execute(IConsoleShell shell, string argStr, string[] args)
var gameMap = IoCManager.Resolve<IGameMapManager>();
var name = args[0];

if (!gameMap.TrySelectMapIfEligible(name))
if (!gameMap.CheckMapExists(name))
{
shell.WriteLine($"No eligible map exists with name {name}.");
shell.WriteLine(Loc.GetString("forcemap-command-map-not-found", ("map", name)));
return;
}

Expand Down
31 changes: 23 additions & 8 deletions Content.Server/Repairable/RepairableSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
using Content.Shared.Database;
using Content.Shared.FixedPoint;
using Content.Shared.Interaction;
using Content.Shared.Mobs;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Popups;
using Content.Shared.Repairable;
using SharedToolSystem = Content.Shared.Tools.Systems.SharedToolSystem;
Expand All @@ -15,6 +18,7 @@ public sealed class RepairableSystem : SharedRepairableSystem
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly IAdminLogManager _adminLogger= default!;
[Dependency] private readonly MobThresholdSystem _mobThresholdSystem = default!;

public override void Initialize()
{
Expand Down Expand Up @@ -78,19 +82,30 @@ public async void Repair(EntityUid uid, RepairableComponent component, InteractU
return;
// Sunrise-end

float delay = component.DoAfterDelay;

// Add a penalty to how long it takes if the user is repairing itself
if (args.User == args.Target)
{
if (!component.AllowSelfRepair)
return;
var isNotSelf = args.User != args.Target;

delay *= component.SelfRepairPenalty;
}
var delay = isNotSelf
? component.DoAfterDelay
: component.DoAfterDelay * GetScaledRepairPenalty(args.User, component);

// Run the repairing doafter
args.Handled = _toolSystem.UseTool(args.Used, args.User, uid, delay, component.QualityNeeded, new RepairFinishedEvent(), component.FuelCost);
}

public float GetScaledRepairPenalty(EntityUid uid, RepairableComponent component)
{
var output = component.DoAfterDelay;
if (!TryComp<MobThresholdsComponent>(uid, out var mobThreshold) ||
!TryComp<DamageableComponent>(uid, out var damageable))
return output;
if (!_mobThresholdSystem.TryGetThresholdForState(uid, MobState.Critical, out var amount, mobThreshold))
return 1;

var percentDamage = (float) (damageable.TotalDamage / amount);
//basically make it scale from 1 to the multiplier.
var modifier = percentDamage * (component.SelfRepairPenalty - 1) + 1;
return Math.Max(modifier, 1);
}
}
}
7 changes: 7 additions & 0 deletions Resources/Changelog/Admin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -330,5 +330,12 @@ Entries:
id: 40
time: '2024-06-21T12:06:07.0000000+00:00'
url: https://github.com/space-wizards/space-station-14/pull/29258
- author: Chief-Engineer
changes:
- message: grant_connect_bypass now requires moderator permissions instead of admin.
type: Tweak
id: 41
time: '2024-06-24T21:56:29.0000000+00:00'
url: https://github.com/space-wizards/space-station-14/pull/29406
Name: Admin
Order: 1
15 changes: 8 additions & 7 deletions Resources/Changelog/Changelog.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
Entries:
- author: Plykiya
changes:
- message: You can now carefully walk over glass shards and D4.
type: Tweak
id: 6315
time: '2024-04-06T04:49:14.0000000+00:00'
url: https://github.com/space-wizards/space-station-14/pull/26763
- author: PursuitInAshes
changes:
- message: Sake Bottles can now be found in the booze-o-mat.
Expand Down Expand Up @@ -3836,3 +3829,11 @@
id: 6814
time: '2024-06-24T15:36:53.0000000+00:00'
url: https://github.com/space-wizards/space-station-14/pull/29404
- author: Emisse
changes:
- message: atmos, elite syndie, and deathsquad hardsuits are now the only fireproof
suits
type: Tweak
id: 6815
time: '2024-06-24T22:03:05.0000000+00:00'
url: https://github.com/space-wizards/space-station-14/pull/29416
1 change: 1 addition & 0 deletions Resources/Locale/en-US/game-ticking/forcemap-command.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
forcemap-command-description = Forces the game to start with a given map next round.
forcemap-command-help = forcemap <map ID>
forcemap-command-need-one-argument = forcemap takes one argument, the path to the map file.
forcemap-command-map-not-found = No eligible map exists with name { $map }.
forcemap-command-success = Forced the game to start with map { $map } next round.
forcemap-command-arg-map = <map ID>
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,6 @@
lowPressureMultiplier: 1000
- type: TemperatureProtection
coefficient: 0.1
- type: FireProtection
reduction: 0.2
- type: Armor
modifiers:
coefficients:
Expand Down Expand Up @@ -266,4 +264,4 @@
slots:
- Hair
- HeadTop
- HeadSide
- HeadSide
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
lowPressureMultiplier: 1000
- type: TemperatureProtection
coefficient: 0.005
- type: FireProtection
reduction: 0.2

#Engineering Hardsuit
- type: entity
Expand Down Expand Up @@ -692,6 +694,8 @@
- type: PressureProtection
highPressureMultiplier: 0.08
lowPressureMultiplier: 1000
- type: FireProtection
reduction: 0.2
- type: Armor
modifiers:
coefficients:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@
lowPressureMultiplier: 1000
- type: TemperatureProtection
coefficient: 0.01
- type: FireProtection
reduction: 0.75 # almost perfectly sealed, atmos firesuit is better
- type: ClothingSpeedModifier
walkModifier: 0.4
sprintModifier: 0.6
Expand Down Expand Up @@ -180,4 +178,4 @@
id: ClothingOuterBaseMedium
components:
- type: Item
size: Huge
size: Huge
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
lowPressureMultiplier: 1000
- type: TemperatureProtection
coefficient: 0.001
- type: FireProtection
reduction: 0.8
- type: ExplosionResistance
damageCoefficient: 0.5
- type: Armor
Expand Down Expand Up @@ -545,7 +547,7 @@
- type: ExplosionResistance
damageCoefficient: 0.2
- type: FireProtection
reduction: 0.8 # perfect protection like atmos firesuit for pyro tf2 ops
reduction: 0.8
- type: Armor
modifiers:
coefficients:
Expand Down Expand Up @@ -862,6 +864,8 @@
coefficient: 0.001
- type: ExplosionResistance
damageCoefficient: 0.2
- type: FireProtection
reduction: 0.8
- type: Armor
modifiers:
coefficients:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@
- type: Synth
- type: Repairable
doAfterDelay: 3
selfRepairPenalty: 2
selfRepairPenalty: 3
damage:
types:
Blunt: -5
Expand Down

0 comments on commit dd9c5a6

Please sign in to comment.