Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
 into restrictedgear
  • Loading branch information
WarMechanic committed Dec 23, 2024
2 parents 9c3ce1b + bfb32cf commit 64af004
Show file tree
Hide file tree
Showing 95 changed files with 2,134 additions and 2,780 deletions.
2 changes: 1 addition & 1 deletion Content.Client/Jittering/JitteringSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private void OnShutdown(EntityUid uid, JitteringComponent jittering, ComponentSh

private void OnAnimationCompleted(EntityUid uid, JitteringComponent jittering, AnimationCompletedEvent args)
{
if(args.Key != _jitterAnimationKey)
if (args.Key != _jitterAnimationKey || jittering.LifeStage >= ComponentLifeStage.Stopping)
return;

if (TryComp(uid, out AnimationPlayerComponent? animationPlayer)
Expand Down
30 changes: 30 additions & 0 deletions Content.Server/Clothing/Systems/LoadoutSystem.Functions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using JetBrains.Annotations;
using Robust.Shared.Serialization.Manager;
using Content.Shared.Clothing.Loadouts.Prototypes;
using Content.Server.NPC.Components;
using Content.Server.NPC.Systems;
using Content.Server.NPC.HTN;
using Content.Server.NPC;
using Robust.Shared.Map;
using System.Numerics;

namespace Content.Server.Clothing.Systems;

[UsedImplicitly]
public sealed partial class LoadoutMakeFollower : LoadoutFunction
{
public override void OnPlayerSpawn(EntityUid character,
EntityUid loadoutEntity,
IComponentFactory factory,
IEntityManager entityManager,
ISerializationManager serializationManager)
{
var npc = entityManager.System<NPCSystem>();
var htn = entityManager.System<HTNSystem>();
if (!entityManager.TryGetComponent<HTNComponent>(loadoutEntity, out var hTNComponent))
return;

npc.SetBlackboard(loadoutEntity, NPCBlackboard.FollowTarget, new EntityCoordinates(character, Vector2.Zero), hTNComponent);
htn.Replan(hTNComponent);
}
}
5 changes: 4 additions & 1 deletion Content.Server/Clothing/Systems/LoadoutSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
using Content.Shared.Storage;
using Content.Shared.Storage.EntitySystems;
using Content.Shared.Traits.Assorted.Components;
using Content.Shared.Whitelist;
using Robust.Shared.Configuration;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
Expand All @@ -33,6 +32,7 @@ public sealed class LoadoutSystem : EntitySystem
[Dependency] private readonly IPrototypeManager _protoMan = default!;
[Dependency] private readonly ISerializationManager _serialization = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly IComponentFactory _componentFactory = default!;


public override void Initialize()
Expand Down Expand Up @@ -103,6 +103,9 @@ public void ApplyCharacterLoadout(
comp.Owner = loadout.Item1;
EntityManager.AddComponent(loadout.Item1, comp);
}

foreach (var function in loadoutProto.Functions)
function.OnPlayerSpawn(uid, loadout.Item1, _componentFactory, EntityManager, _serialization);
}


Expand Down
61 changes: 61 additions & 0 deletions Content.Server/Traits/TraitSystem.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
using System.Linq;
using Content.Server.Administration.Logs;
using Content.Server.Administration.Systems;
using Content.Server.Chat.Managers;
using Content.Server.GameTicking;
using Content.Server.Players.PlayTimeTracking;
using Content.Shared.CCVar;
using Content.Shared.Chat;
using Content.Shared.Customization.Systems;
using Content.Shared.Database;
using Content.Shared.Players;
using Content.Shared.Roles;
using Content.Shared.Traits;
using Robust.Server.Player;
using Robust.Shared.Configuration;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Serialization.Manager;
using Robust.Shared.Utility;
using Timer = Robust.Shared.Timing.Timer;

namespace Content.Server.Traits;

Expand All @@ -20,6 +29,11 @@ public sealed class TraitSystem : EntitySystem
[Dependency] private readonly PlayTimeTrackingManager _playTimeTracking = default!;
[Dependency] private readonly IConfigurationManager _configuration = default!;
[Dependency] private readonly IComponentFactory _componentFactory = default!;
[Dependency] private readonly IAdminLogManager _adminLog = default!;
[Dependency] private readonly AdminSystem _adminSystem = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly IChatManager _chatManager = default!;

public override void Initialize()
{
Expand All @@ -31,6 +45,9 @@ public override void Initialize()
// When the player is spawned in, add all trait components selected during character creation
private void OnPlayerSpawnComplete(PlayerSpawnCompleteEvent args)
{
var pointsTotal = _configuration.GetCVar(CCVars.GameTraitsDefaultPoints);
var traitSelections = _configuration.GetCVar(CCVars.GameTraitsMax);

foreach (var traitId in args.Profile.TraitPreferences)
{
if (!_prototype.TryIndex<TraitPrototype>(traitId, out var traitPrototype))
Expand All @@ -47,8 +64,15 @@ private void OnPlayerSpawnComplete(PlayerSpawnCompleteEvent args)
out _))
continue;

// To check for cheaters. :FaridaBirb.png:
pointsTotal += traitPrototype.Points;
--traitSelections;

AddTrait(args.Mob, traitPrototype);
}

if (pointsTotal < 0 || traitSelections < 0)
PunishCheater(args.Mob);
}

/// <summary>
Expand All @@ -59,4 +83,41 @@ public void AddTrait(EntityUid uid, TraitPrototype traitPrototype)
foreach (var function in traitPrototype.Functions)
function.OnPlayerSpawn(uid, _componentFactory, EntityManager, _serialization);
}

/// <summary>
/// On a non-cheating client, it's not possible to save a character with a negative number of traits. This can however
/// trigger incorrectly if a character was saved, and then at a later point in time an admin changes the traits Cvars to reduce the points.
/// Or if the points costs of traits is increased.
/// </summary>
private void PunishCheater(EntityUid uid)
{
_adminLog.Add(LogType.AdminMessage, LogImpact.High,
$"{ToPrettyString(uid):entity} attempted to spawn with an invalid trait list. This might be a mistake, or they might be cheating");

if (!_configuration.GetCVar(CCVars.TraitsPunishCheaters)
|| !_playerManager.TryGetSessionByEntity(uid, out var targetPlayer))
return;

// For maximum comedic effect, this is plenty of time for the cheater to get on station and start interacting with people.
var timeToDestroy = _random.NextFloat(120, 360);

Timer.Spawn(TimeSpan.FromSeconds(timeToDestroy), () => VaporizeCheater(targetPlayer));
}

/// <summary>
/// https://www.youtube.com/watch?v=X2QMN0a_TrA
/// </summary>
private void VaporizeCheater (Robust.Shared.Player.ICommonSession targetPlayer)
{
_adminSystem.Erase(targetPlayer);

var feedbackMessage = $"[font size=24][color=#ff0000]{"You have spawned in with an illegal trait point total. If this was a result of cheats, then your nonexistence is a skill issue. Otherwise, feel free to click 'Return To Lobby', and fix your trait selections."}[/color][/font]";
_chatManager.ChatMessageToOne(
ChatChannel.Emotes,
feedbackMessage,
feedbackMessage,
EntityUid.Invalid,
false,
targetPlayer.Channel);
}
}
7 changes: 7 additions & 0 deletions Content.Shared/CCVar/CCVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,13 @@ public static readonly CVarDef<bool>
public static readonly CVarDef<int> GameTraitsDefaultPoints =
CVarDef.Create("game.traits_default_points", 10, CVar.REPLICATED);

/// <summary>
/// Whether the game will SMITE people who used cheat engine to spawn with all of the traits.
/// Illegal trait totals will still be logged even if this is disabled.
/// If you are intending to decrease the trait points availability, or modify the costs of traits, consider temporarily disabling this.
/// </summary>
public static readonly CVarDef<bool> TraitsPunishCheaters =
CVarDef.Create("game.traits_punish_cheaters", true, CVar.REPLICATED);

/// <summary>
/// Whether to allow characters to select loadout items.
Expand Down
16 changes: 16 additions & 0 deletions Content.Shared/Clothing/Loadouts/Prototypes/LoadoutPrototype.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Content.Shared.Customization.Systems;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.Manager;

namespace Content.Shared.Clothing.Loadouts.Prototypes;

Expand Down Expand Up @@ -45,4 +46,19 @@ public sealed partial class LoadoutPrototype : IPrototype

[DataField]
public string GuideEntry { get; } = "";

[DataField(serverOnly: true)]
public LoadoutFunction[] Functions { get; private set; } = Array.Empty<LoadoutFunction>();
}

/// This serves as a hook for loadout functions to modify one or more entities upon spawning in.
[ImplicitDataDefinitionForInheritors]
public abstract partial class LoadoutFunction
{
public abstract void OnPlayerSpawn(
EntityUid character,
EntityUid loadoutEntity,
IComponentFactory factory,
IEntityManager entityManager,
ISerializationManager serializationManager);
}
74 changes: 74 additions & 0 deletions Resources/Changelog/Changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8713,3 +8713,77 @@ Entries:
id: 6583
time: '2024-12-18T01:32:32.0000000+00:00'
url: https://github.com/Simple-Station/Einstein-Engines/pull/1357
- author: VMSolidus
changes:
- type: Fix
message: Fixed the Saltern bridge being a hard vacuum at roundstart.
id: 6584
time: '2024-12-19T22:52:32.0000000+00:00'
url: https://github.com/Simple-Station/Einstein-Engines/pull/1359
- author: VMSolidus
changes:
- type: Add
message: >-
Added labels to all generic colorable items in loadouts, so that players
can see which items have custom colors as customization options.
- type: Remove
message: >-
Removed all 'specific color' variants of colorable items from Loadouts,
such as "Blue Jumpsuit" when a colorable jumpsuit exists.
id: 6585
time: '2024-12-21T18:02:28.0000000+00:00'
url: https://github.com/Simple-Station/Einstein-Engines/pull/1364
- author: VMSolidus
changes:
- type: Add
message: >-
Added colorable variants of fingerless gloves, headbands, berets,
hairflowers, cloth masks, and the neck gaiter.
id: 6586
time: '2024-12-21T19:25:13.0000000+00:00'
url: https://github.com/Simple-Station/Einstein-Engines/pull/1365
- author: VMSolidus
changes:
- type: Add
message: Loadouts can now apply modular functions to items upon spawning in.
- type: Add
message: >-
A new LoadoutMakeFollower function, which lets you buy NPC followers in
loadouts.
- type: Add
message: >-
added Pet Mice, Cockroach, Mothroach, and Hamster to Loadouts. All of
which use the new LoadoutMakeFollower function.
id: 6587
time: '2024-12-22T10:26:41.0000000+00:00'
url: https://github.com/Simple-Station/Einstein-Engines/pull/1366
- author: juniwoofs
changes:
- type: Add
message: two new cuddly friends to the station! (harpy and morty plush)
id: 6588
time: '2024-12-22T19:24:58.0000000+00:00'
url: https://github.com/Simple-Station/Einstein-Engines/pull/1369
- author: VMSolidus
changes:
- type: Add
message: >-
Implemented Anti-cheat for Traits. Attempting to join a round with an
illegal traits list will result in hilarious consequences.
id: 6589
time: '2024-12-22T19:55:22.0000000+00:00'
url: https://github.com/Simple-Station/Einstein-Engines/pull/1358
- author: VMSolidus
changes:
- type: Add
message: Prisoners now spawn with a Pacifier Implant.
id: 6590
time: '2024-12-22T19:56:21.0000000+00:00'
url: https://github.com/Simple-Station/Einstein-Engines/pull/1341
- author: sleepyyapril
changes:
- type: Fix
message: Fixed jittering displacing your character when shaken.
id: 6591
time: '2024-12-22T19:57:10.0000000+00:00'
url: https://github.com/Simple-Station/Einstein-Engines/pull/1334
1 change: 1 addition & 0 deletions Resources/Locale/en-US/forensics/fibers.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ fibers-white = white
fibers-yellow = yellow
fibers-regal-blue = regal blue
fibers-olive = olive
fibers-dyed = dyed fibers
3 changes: 3 additions & 0 deletions Resources/Locale/en-US/loadouts/generic/back.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
loadout-name-LoadoutBackpack = grey backpack (colorable)
loadout-name-LoadoutBackpackDuffel = grey duffelbag (colorable)
loadout-name-LoadoutBackpackSatchel = grey satchel (colorable)
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ loadout-description-LoadoutEyesBlindfold = Why would you want this?
loadout-name-LoadoutItemBlindfoldFake = "blind"fold
loadout-description-LoadoutItemBlindfoldFake = This product may not work as advertised.
loadout-name-LoadoutEyesGlasses = glasses (colorable)
2 changes: 2 additions & 0 deletions Resources/Locale/en-US/loadouts/generic/hands.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
loadout-name-LoadoutHandsColorWhite = gloves (colorable)
loadout-name-LoadoutHandsGlovesFingerlessWhite = fingerless gloves (colorable)
15 changes: 15 additions & 0 deletions Resources/Locale/en-US/loadouts/generic/head.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
loadout-description-LoadoutHeadBeaverHat = Gentlemen.
loadout-description-LoadoutHeadTophat = A stylish black tophat.
loadout-name-LoadoutHeadFedoraWhite = fedora (colorable)
loadout-name-LoadoutHeadHatCowboyWhite = cowboy hat (colorable)
loadout-name-LoadoutHeadHatMimesoft = baseball cap (colorable)
loadout-name-LoadoutHeadHatMimesoftFlipped = baseball cap (colorable, flipped)
loadout-name-LoadoutHeadHijabColorable = hijab (colorable)
loadout-name-LoadoutHeadTurbanColorable = turban (colorable)
loadout-name-LoadoutHeadKippahColorable = kippah (colorable)
loadout-name-LoadoutHeadTinfoil = tinfoil hat (colorable)
loadout-name-LoadoutHeadHatCowboyBountyHunter = bounty hunter hat (colorable)
loadout-name-LoadoutHeadBandWhite = headband (colorable)
loadout-name-LoadoutHeadBeretWhite = beret (colorable)
loadout-name-LoadoutHeadPoppyWhite = hair flower (colorable)
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,15 @@ loadout-name-LoadoutItemBoxSurvivalSecurity = survival box (security)
loadout-name-LoadoutItemBoxSurvivalBrigmedic = survival box (corpsman)
loadout-name-LoadoutItemBoxSurvivalMedical = survival box (medical)
loadout-name-LoadoutItemBoxHug = box of hugs (clown)
loadout-name-LoadoutItemLighter = lighter (colorable)
loadout-name-LoadoutItemLighterCheap = cheap lighter (colorable)
loadout-name-LoadoutItemLighterFlippo = flippo lighter (colorable)
loadout-name-LoadoutItemDrinkShinyFlask = shiny flask (colorable)
loadout-name-LoadoutItemDrinkLithiumFlask = lithium flask (colorable)
loadout-name-LoadoutItemDrinkVacuumFlask = vacuum flask (colorable)
loadout-name-LoadoutItemPetMouse = pet mouse
loadout-name-LoadoutItemPetHamster = pet hamster
loadout-name-LoadoutItemPetMothroach = pet mothroach
loadout-name-LoadoutItemPetCockroach = pet cockroach
3 changes: 3 additions & 0 deletions Resources/Locale/en-US/loadouts/generic/mask.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
loadout-name-LoadoutMaskBandWhite = cloth mask (colorable)
loadout-name-LoadoutMaskNeckGaiterWhite = neck gaiter (colorable)
loadout-name-LoadoutMaskSterile = sterile mask (colorable)
4 changes: 4 additions & 0 deletions Resources/Locale/en-US/loadouts/generic/neck.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
loadout-name-LoadoutNeckOldMantle = old mantle (colorable)
loadout-name-LoadoutNeckUnathiMantle = unathi mantle (colorable)
loadout-name-LoadoutNeckTieWhite = suit tie (colorable)
loadout-name-LoadoutNeckBedsheetWhite = bedsheet (colorable)
11 changes: 11 additions & 0 deletions Resources/Locale/en-US/loadouts/generic/outerClothing.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
loadout-description-LoadoutOuterGhostSheet = Spooky...
loadout-description-LoadoutOuterCoatBomberjacket = A sleek bomber jacket.
loadout-description-LoadoutOuterCoatHoodieBlack = A warm hoodie.
loadout-description-LoadoutOuterCoatHoodieGrey = A warm hoodie.
loadout-description-LoadoutOuterCoatWinterCoat = For keeping nice and snug.
loadout-name-LoadoutOuterCoatHoodieGrey = grey hoodie (colorable)
loadout-name-LoadoutOuterCoatWinterCoat = winter coat (colorable)
loadout-name-LoadoutOuterCoatHyenhSweater = sweater (colorable)
loadout-name-LoadoutOuterWinterCoatLong = long winter coat (colorable)
loadout-name-LoadoutOuterCoatMNKWhiteHoodie = MNK hoodie (colorable)
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@ loadout-description-LoadoutShoesRed = Embrace the spirit of exploration with the
loadout-description-LoadoutShoesWhite = Elevate your style with these pristine white shoes, a symbol of innovation and progress.
loadout-description-LoadoutShoesYellow = Light up the space station with these radiant yellow shoes, bringing a burst of energy to your every step.
loadout-description-LoadoutShoesSlippersDuck = Quack up your downtime with these adorable duck slippers that waddle the line between comfort and quirkiness.
loadout-name-LoadoutShoesWhite = shoes (colorable)
loadout-name-LoadoutShoesBootsCowboyWhite = cowboy boots (colorable)
loadout-name-LoadoutShoesBootsCowboyFancy = fancy cowboy boots (colorable)
loadout-name-LoadoutShoesMiscWhite = misc shoes (colorable)
loadout-name-LoadoutShoesClothWrap = cloth foot wraps (colorable)
12 changes: 12 additions & 0 deletions Resources/Locale/en-US/loadouts/generic/uniform.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
loadout-description-LoadoutUniformAncientJumpsuit = The legend of the Greytide.
loadout-name-LoadoutUniformJumpsuitColorWhite = jumpsuit (colorable)
loadout-name-LoadoutUniformJumpskirtColorWhite = jumpskirt (colorable)
loadout-name-LoadoutUniformMartialGi = gi (colorable)
loadout-name-LoadoutClothingJumpsuitKimono = kimono (colorable)
loadout-name-LoadoutClothingMNKOfficeSkirt = MNK office skirt (colorable)
loadout-name-LoadoutClothingMNKUnderGarment = MNK under garment (colorable)
loadout-name-LoadoutClothingMNKGymBra = MNK gym bra (colorable)
loadout-name-LoadoutClothingJumpsuitSuitWhite = business suit (colorable)
loadout-name-LoadoutClothingJumpsuitSuitWhiteAlt = business suit (alt, colorable)
loadout-name-LoadoutClothingJumpsuitSuitWhiteMob = mob suit (colorable)
2 changes: 0 additions & 2 deletions Resources/Locale/en-US/loadouts/head.ftl

This file was deleted.

1 change: 1 addition & 0 deletions Resources/Locale/en-US/loadouts/itemgroups.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ character-item-group-LoadoutInstrumentsAny = Musical Instruments (Non-Musician)
character-item-group-LoadoutSmokes = Smokeables
character-item-group-LoadoutBoxKits = Survival Kits
character-item-group-LoadoutWritables = Writing Tools
character-item-group-LoadoutPets = Pets
# Job Specific Template
character-item-group-LoadoutJOBBackpacks = JOB Backpacks
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
loadout-name-LoadoutEngineeringHeadHardhatWhite = hardhat (colorable)
Loading

0 comments on commit 64af004

Please sign in to comment.