mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-18 05:59:03 +03:00
# Description Adds the Ghost Bar from Goob LRP. Upon spawn, the character's loadouts and traits will also be applied as if their job was their Ghost Bar job. Adjusts the weights for kill objectives, re-enabling the kill objective and reducing the weight of Teach a Lesson now that there's more things to do after getting round removed. Goobstation cherry-picked PRs: - https://github.com/Goob-Station/Goob-Station/pull/454 - https://github.com/Goob-Station/Goob-Station/pull/464 - https://github.com/Goob-Station/Goob-Station/pull/689 (partially applied to Ghost bar files only) - https://github.com/Goob-Station/Goob-Station/pull/963 - https://github.com/Goob-Station/Goob-Station/pull/974 - https://github.com/Goob-Station/Goob-Station/pull/982 (partially applied to Ghost bar files only) - https://github.com/Goob-Station/Goob-Station/pull/1288 (partially applied to Ghost bar files only) Wizden cherry-picked PRs: - https://github.com/space-wizards/space-station-14/pull/29103 (for the foam force rifle that spawns in the Ghost bar) ## Media **Ghost Bar UI**  **Ghost Bar In-Game**  Notice how the Ghost Bar character has loadout items in the backpack and the Skeleton Accent trait. ## Changelog <!-- You can add an author after the `🆑` to change the name that appears in the changelog (ex: `🆑 Death`) Leaving it blank will default to your GitHub display name This includes all available types for the changelog --> 🆑 Skubman - add: Ghost Bar! When you die, you can now go to the Ghost Bar to chill and talk about the round with other ghosts. (by Aidenkrz) - add: Foam Force rifle to cargo lottery! (by IProduceWidgets) - add: Re-enabled the Kill objective for traitors. - tweak: Reduced the chances of traitors getting the "Teach a Lesson" objective. --------- Co-authored-by: Aiden <aiden@djkraz.com> Co-authored-by: Rank #1 Jonestown partygoer <mary@thughunt.ing> Co-authored-by: IProduceWidgets <107586145+IProduceWidgets@users.noreply.github.com> Co-authored-by: Aviu00 <93730715+Aviu00@users.noreply.github.com> (cherry picked from commit 0b4ceb21cc406cd39b894afe79decf40c2366369)
140 lines
5.9 KiB
C#
140 lines
5.9 KiB
C#
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.Preferences;
|
|
using Content.Shared.Roles;
|
|
using Content.Shared.Traits;
|
|
using Robust.Server.Player;
|
|
using Robust.Shared.Configuration;
|
|
using Content.Shared.Whitelist;
|
|
using Robust.Shared.Player;
|
|
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;
|
|
|
|
public sealed class TraitSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly IPrototypeManager _prototype = default!;
|
|
[Dependency] private readonly ISerializationManager _serialization = default!;
|
|
[Dependency] private readonly CharacterRequirementsSystem _characterRequirements = default!;
|
|
[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()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<PlayerSpawnCompleteEvent>(OnPlayerSpawnComplete);
|
|
}
|
|
|
|
// When the player is spawned in, add all trait components selected during character creation
|
|
private void OnPlayerSpawnComplete(PlayerSpawnCompleteEvent args) =>
|
|
ApplyTraits(args.Mob, args.JobId, args.Profile,
|
|
_playTimeTracking.GetTrackerTimes(args.Player), args.Player.ContentData()?.Whitelisted ?? false);
|
|
|
|
/// <summary>
|
|
/// Adds the traits selected by a player to an entity.
|
|
/// </summary>
|
|
public void ApplyTraits(EntityUid uid, ProtoId<JobPrototype>? jobId, HumanoidCharacterProfile profile,
|
|
Dictionary<string, TimeSpan> playTimes, bool whitelisted, bool punishCheater = true)
|
|
{
|
|
var pointsTotal = _configuration.GetCVar(CCVars.GameTraitsDefaultPoints);
|
|
var traitSelections = _configuration.GetCVar(CCVars.GameTraitsMax);
|
|
if (jobId is not null && !_prototype.TryIndex(jobId, out var jobPrototype)
|
|
&& jobPrototype is not null && !jobPrototype.ApplyTraits)
|
|
return;
|
|
|
|
var jobPrototypeToUse = _prototype.Index(jobId ?? _prototype.EnumeratePrototypes<JobPrototype>().First().ID);
|
|
|
|
foreach (var traitId in profile.TraitPreferences)
|
|
{
|
|
if (!_prototype.TryIndex<TraitPrototype>(traitId, out var traitPrototype))
|
|
{
|
|
DebugTools.Assert($"No trait found with ID {traitId}!");
|
|
return;
|
|
}
|
|
|
|
if (!_characterRequirements.CheckRequirementsValid(
|
|
traitPrototype.Requirements,
|
|
jobPrototypeToUse,
|
|
profile, playTimes, whitelisted, traitPrototype,
|
|
EntityManager, _prototype, _configuration,
|
|
out _))
|
|
continue;
|
|
|
|
// To check for cheaters. :FaridaBirb.png:
|
|
pointsTotal += traitPrototype.Points;
|
|
--traitSelections;
|
|
|
|
AddTrait(uid, traitPrototype);
|
|
}
|
|
|
|
if (punishCheater && (pointsTotal < 0 || traitSelections < 0))
|
|
PunishCheater(uid);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Adds a single Trait Prototype to an Entity.
|
|
/// </summary>
|
|
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);
|
|
}
|
|
}
|