From 58c6fae48a3df54b9414d9fd49f0b4a9ea2ce8fa Mon Sep 17 00:00:00 2001 From: Finket Date: Sun, 25 Feb 2024 20:03:07 +0200 Subject: [PATCH 1/7] Port over drop on slip files --- .../Slippery/DropOnSlipComponent.cs | 16 +++ .../Slippery/DropOnSlipSystem.cs | 98 +++++++++++++++ Content.Shared/Slippery/SlipperySystem.cs | 9 ++ .../Content/Slippery/dropOnSlip.ftl | 5 + .../Entities/Clothing/Ears/headsets.yml | 2 + .../Entities/Clothing/Ears/headsets_alt.yml | 2 + .../Entities/Clothing/Eyes/glasses.yml | 8 ++ .../Prototypes/Entities/Clothing/Eyes/hud.yml | 6 + .../Entities/Clothing/Head/hardhats.yml | 2 + .../Entities/Clothing/Head/hats.yml | 116 ++++++++++++++++-- .../Entities/Clothing/Head/misc.yml | 12 +- .../Entities/Clothing/Head/soft.yml | 60 +++++++++ .../Entities/Clothing/Masks/masks.yml | 2 + 13 files changed, 327 insertions(+), 11 deletions(-) create mode 100644 Content.Server/SimpleStation14/Slippery/DropOnSlipComponent.cs create mode 100644 Content.Server/SimpleStation14/Slippery/DropOnSlipSystem.cs create mode 100644 Resources/Locale/en-US/simplestation14/Content/Slippery/dropOnSlip.ftl diff --git a/Content.Server/SimpleStation14/Slippery/DropOnSlipComponent.cs b/Content.Server/SimpleStation14/Slippery/DropOnSlipComponent.cs new file mode 100644 index 0000000000..89ba354c43 --- /dev/null +++ b/Content.Server/SimpleStation14/Slippery/DropOnSlipComponent.cs @@ -0,0 +1,16 @@ +namespace Content.Server.SimpleStation14.Slippery; + +/// +/// Uses provided chance to try and drop the item when slipped, if equipped. +/// +[RegisterComponent] +public sealed partial class DropOnSlipComponent : Component +{ + [DataField("chance")] + [ViewVariables(VVAccess.ReadWrite)] + public int Chance = 20; + + [DataField("chanceToThrow")] + [ViewVariables(VVAccess.ReadWrite)] + public int ChanceToThrow = 40; +} diff --git a/Content.Server/SimpleStation14/Slippery/DropOnSlipSystem.cs b/Content.Server/SimpleStation14/Slippery/DropOnSlipSystem.cs new file mode 100644 index 0000000000..aa1d894dae --- /dev/null +++ b/Content.Server/SimpleStation14/Slippery/DropOnSlipSystem.cs @@ -0,0 +1,98 @@ +using System.Numerics; +using Content.Shared.Administration.Logs; +using Content.Shared.Database; +using Content.Shared.Inventory; +using Robust.Shared.Random; +using Content.Server.Popups; +using Content.Shared.Popups; +using Content.Shared.Slippery; +using Content.Shared.Interaction.Components; +using Robust.Shared.Physics.Systems; +using Robust.Shared.Physics.Components; +using Content.Shared.Throwing; + +namespace Content.Server.SimpleStation14.Slippery; + +public sealed class DropOnSlipSystem : EntitySystem +{ + [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!; + [Dependency] private readonly PopupSystem _popup = default!; + [Dependency] private readonly IRobustRandom _random = default!; + [Dependency] private readonly InventorySystem _invSystem = default!; + [Dependency] private readonly SharedPhysicsSystem _physics = default!; + [Dependency] private readonly ThrowingSystem _throwing = default!; + + private static readonly float PocketDropChance = 10f; + private static readonly float PocketThrowChance = 5f; + + private static readonly float ClumsyDropChance = 5f; + private static readonly float ClumsyThrowChance = 90f; + + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(HandleSlip); + } + + + private void HandleSlip(EntityUid entity, InventoryComponent invComp, ParkSlipEvent args) + { + if (!_invSystem.TryGetSlots(entity, out var slotDefinitions)) + return; + + foreach (var slot in slotDefinitions) + { + if (!_invSystem.TryGetSlotEntity(entity, slot.Name, out var item)) + continue; + + // A check for DropOnSlipComponent. + if (slot.Name != "pocket1" && slot.Name != "pocket2" && EntityManager.TryGetComponent(item, out var dropComp) && _random.NextFloat(0, 100) < dropComp.Chance) + { + var popupString = Loc.GetString("system-drop-on-slip-text-component", ("name", entity), ("item", item)); + + Drop(entity, item.Value, slot.Name, popupString); + continue; + } + + // A check for any items in pockets. + if (slot.Name == "pocket1" | slot.Name == "pocket2" && _random.NextFloat(0, 100) < PocketDropChance) + { + var popupString = Loc.GetString("system-drop-on-slip-text-pocket", ("name", entity), ("item", item)); + + Drop(entity, item.Value, slot.Name, popupString); + continue; + } + + // A check for ClumsyComponent. + if (slot.Name != "jumpsuit" && _random.NextFloat(0, 100) < ClumsyDropChance && HasComp(entity)) + { + var popupString = Loc.GetString("system-drop-on-slip-text-clumsy", ("name", entity), ("item", item)); + + Drop(entity, item.Value, slot.Name, popupString); + continue; + } + } + } + + private void Drop(EntityUid entity, EntityUid item, string slot, string popupString) + { + if (!_invSystem.TryUnequip(entity, slot, false, true)) + return; + + EntityManager.TryGetComponent(entity, out var entPhysComp); + + if (entPhysComp != null) + { + var strength = entPhysComp.LinearVelocity.Length() / 1.5f; + Vector2 direction = new Vector2(_random.Next(-8, 8), _random.Next(-8, 8)); + + _throwing.TryThrow(item, direction, strength, entity); + } + + _popup.PopupEntity(popupString, item, PopupType.MediumCaution); + + var logMessage = Loc.GetString("system-drop-on-slip-log", ("entity", ToPrettyString(entity)), ("item", ToPrettyString(item))); + _adminLogger.Add(LogType.Slip, LogImpact.Low, $"{logMessage}"); + } +} diff --git a/Content.Shared/Slippery/SlipperySystem.cs b/Content.Shared/Slippery/SlipperySystem.cs index 1f602b9b52..d658b7a40f 100644 --- a/Content.Shared/Slippery/SlipperySystem.cs +++ b/Content.Shared/Slippery/SlipperySystem.cs @@ -87,6 +87,8 @@ private void TrySlip(EntityUid uid, SlipperyComponent component, EntityUid other _stun.TryParalyze(other, TimeSpan.FromSeconds(component.ParalyzeTime), true); + RaiseLocalEvent(other, new ParkSlipEvent(uid)); // Parkstation-DropOnSlip + // Preventing from playing the slip sound when you are already knocked down. if (playSound) { @@ -111,3 +113,10 @@ public sealed class SlipAttemptEvent : CancellableEntityEventArgs, IInventoryRel /// [ByRefEvent] public readonly record struct SlipEvent(EntityUid Slipped); + +// Parkstation-DropOnSlip-Start +/// +/// This is an event raised on an entity after they slip. Duh. +/// +public readonly record struct ParkSlipEvent(EntityUid Tripper); +// Parkstation-DropOnSlip-End diff --git a/Resources/Locale/en-US/simplestation14/Content/Slippery/dropOnSlip.ftl b/Resources/Locale/en-US/simplestation14/Content/Slippery/dropOnSlip.ftl new file mode 100644 index 0000000000..518e2028e6 --- /dev/null +++ b/Resources/Locale/en-US/simplestation14/Content/Slippery/dropOnSlip.ftl @@ -0,0 +1,5 @@ +system-drop-on-slip-text-component = {$name}'s {$item} slips off! +system-drop-on-slip-text-pocket = Something falls out of {$name}'s pocket! +system-drop-on-slip-text-clumsy = The {$item} tumbles off of {$name}! + +system-drop-on-slip-log = {$entity} dropped {$item} when slipping. diff --git a/Resources/Prototypes/Entities/Clothing/Ears/headsets.yml b/Resources/Prototypes/Entities/Clothing/Ears/headsets.yml index df160f8e5a..04a22a4f7b 100644 --- a/Resources/Prototypes/Entities/Clothing/Ears/headsets.yml +++ b/Resources/Prototypes/Entities/Clothing/Ears/headsets.yml @@ -26,6 +26,8 @@ - type: GuideHelp guides: - Radio + - type: DropOnSlip + chance: 5 - type: entity parent: ClothingHeadset diff --git a/Resources/Prototypes/Entities/Clothing/Ears/headsets_alt.yml b/Resources/Prototypes/Entities/Clothing/Ears/headsets_alt.yml index 5dfa1df150..ca66723b2a 100644 --- a/Resources/Prototypes/Entities/Clothing/Ears/headsets_alt.yml +++ b/Resources/Prototypes/Entities/Clothing/Ears/headsets_alt.yml @@ -9,6 +9,8 @@ state: icon_alt - type: Clothing equippedPrefix: alt + - type: DropOnSlip + chance: 0 - type: entity parent: ClothingHeadsetAlt diff --git a/Resources/Prototypes/Entities/Clothing/Eyes/glasses.yml b/Resources/Prototypes/Entities/Clothing/Eyes/glasses.yml index 79446d8633..86d2d4dbb2 100644 --- a/Resources/Prototypes/Entities/Clothing/Eyes/glasses.yml +++ b/Resources/Prototypes/Entities/Clothing/Eyes/glasses.yml @@ -66,6 +66,8 @@ - type: Tag tags: - SecDogWearable # DeltaV - let Laika wear meson goggles + - type: DropOnSlip + chance: 30 - type: entity parent: ClothingEyesBase @@ -83,6 +85,8 @@ - HamsterWearable - WhitelistChameleon - GlassesNearsight # SimpleStation14 NearsightedTrait + - type: DropOnSlip + chance: 30 - type: entity parent: ClothingEyesBase @@ -147,6 +151,8 @@ - SecDogWearable # DeltaV - let Laika wear sunglasses - type: IdentityBlocker coverage: EYES + - type: DropOnSlip + chance: 30 - type: entity parent: ClothingEyesBase @@ -203,6 +209,8 @@ coefficients: Heat: 0.95 - type: GroupExamine + - type: DropOnSlip + chance: 30 - type: entity parent: ClothingEyesBase diff --git a/Resources/Prototypes/Entities/Clothing/Eyes/hud.yml b/Resources/Prototypes/Entities/Clothing/Eyes/hud.yml index 89010ca30e..3cdca9cb93 100644 --- a/Resources/Prototypes/Entities/Clothing/Eyes/hud.yml +++ b/Resources/Prototypes/Entities/Clothing/Eyes/hud.yml @@ -12,6 +12,8 @@ damageContainers: - Inorganic - Silicon + - type: DropOnSlip + chance: 25 - type: entity parent: ClothingEyesBase @@ -32,6 +34,8 @@ - type: Tag tags: - HudMedical + - type: DropOnSlip + chance: 25 - type: entity parent: ClothingEyesBase @@ -47,6 +51,8 @@ - type: Tag tags: - HudSecurity + - type: DropOnSlip + chance: 25 - type: entity parent: ClothingEyesBase diff --git a/Resources/Prototypes/Entities/Clothing/Head/hardhats.yml b/Resources/Prototypes/Entities/Clothing/Head/hardhats.yml index 3e291f5dff..6b68c0e326 100644 --- a/Resources/Prototypes/Entities/Clothing/Head/hardhats.yml +++ b/Resources/Prototypes/Entities/Clothing/Head/hardhats.yml @@ -62,6 +62,8 @@ - type: ContainerContainer containers: cell_slot: !type:ContainerSlot + - type: DropOnSlip + chance: 15 - type: entity parent: ClothingHeadHatHardhatBase diff --git a/Resources/Prototypes/Entities/Clothing/Head/hats.yml b/Resources/Prototypes/Entities/Clothing/Head/hats.yml index 1e38246bd0..390ab69b32 100644 --- a/Resources/Prototypes/Entities/Clothing/Head/hats.yml +++ b/Resources/Prototypes/Entities/Clothing/Head/hats.yml @@ -8,6 +8,8 @@ sprite: Clothing/Head/Hats/beaver_hat.rsi - type: Clothing sprite: Clothing/Head/Hats/beaver_hat.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -24,6 +26,8 @@ - ClothMade - HamsterWearable - WhitelistChameleon + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -40,6 +44,8 @@ - ClothMade - HamsterWearable - WhitelistChameleon + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -47,10 +53,12 @@ name: casa description: Cone-shaped hat components: - - type: Sprite - sprite: Clothing/Head/Hats/casa.rsi - - type: Clothing - sprite: Clothing/Head/Hats/casa.rsi + - type: Sprite + sprite: Clothing/Head/Hats/casa.rsi + - type: Clothing + sprite: Clothing/Head/Hats/casa.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -83,6 +91,8 @@ - ClothMade - HamsterWearable - WhitelistChameleon + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -99,6 +109,8 @@ - ClothMade - HamsterWearable - WhitelistChameleon + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -110,6 +122,8 @@ sprite: DeltaV/Clothing/Head/Hats/beret_warden.rsi # DeltaV - resprite - type: Clothing sprite: DeltaV/Clothing/Head/Hats/beret_warden.rsi # DeltaV - resprite + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -121,6 +135,8 @@ sprite: Clothing/Head/Hats/beret_physician.rsi - type: Clothing sprite: Clothing/Head/Hats/beret_physician.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -132,6 +148,8 @@ sprite: Clothing/Head/Hats/beret_brigmedic.rsi - type: Clothing sprite: Clothing/Head/Hats/beret_brigmedic.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -154,6 +172,8 @@ sprite: Clothing/Head/Hats/bowler_hat.rsi - type: Clothing sprite: Clothing/Head/Hats/bowler_hat.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -170,6 +190,8 @@ - ClothMade - HamsterWearable - WhitelistChameleon + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -185,6 +207,8 @@ proto: robot - type: IdentityBlocker - type: IngestionBlocker + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -196,6 +220,8 @@ sprite: Clothing/Head/Hats/centcom.rsi - type: Clothing sprite: Clothing/Head/Hats/centcom.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -222,6 +248,8 @@ - ClothMade - HamsterWearable - WhitelistChameleon + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -238,6 +266,8 @@ - ClothMade - HamsterWearable - WhitelistChameleon + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -249,6 +279,8 @@ sprite: Clothing/Head/Hats/greyfedora.rsi - type: Clothing sprite: Clothing/Head/Hats/greyfedora.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -260,6 +292,8 @@ sprite: Clothing/Head/Hats/fez.rsi - type: Clothing sprite: Clothing/Head/Hats/fez.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -276,6 +310,8 @@ - ClothMade - HamsterWearable - WhitelistChameleon + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -292,6 +328,8 @@ - ClothMade - HamsterWearable - WhitelistChameleon + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -303,6 +341,8 @@ sprite: Clothing/Head/Hats/outlawhat.rsi - type: Clothing sprite: Clothing/Head/Hats/outlawhat.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -314,6 +354,8 @@ sprite: Clothing/Head/Hats/witchhat.rsi - type: Clothing sprite: Clothing/Head/Hats/witchhat.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -325,6 +367,8 @@ sprite: Clothing/Head/Hats/paper.rsi - type: Clothing sprite: Clothing/Head/Hats/paper.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -336,6 +380,8 @@ sprite: Clothing/Head/Hats/pirate.rsi - type: Clothing sprite: Clothing/Head/Hats/pirate.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -347,6 +393,8 @@ sprite: Clothing/Head/Hats/plaguedoctor.rsi - type: Clothing sprite: Clothing/Head/Hats/plaguedoctor.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -374,6 +422,8 @@ sprite: Clothing/Head/Hats/santahat.rsi - type: Clothing sprite: Clothing/Head/Hats/santahat.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -387,6 +437,8 @@ sprite: Clothing/Head/Hats/sombrero.rsi - type: AddAccentClothing accent: SpanishAccent + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -403,6 +455,8 @@ - ClothMade - HamsterWearable - WhitelistChameleon + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -414,6 +468,8 @@ sprite: Clothing/Head/Hats/surgcap_green.rsi - type: Clothing sprite: Clothing/Head/Hats/surgcap_green.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -425,6 +481,8 @@ sprite: Clothing/Head/Hats/surgcap_purple.rsi - type: Clothing sprite: Clothing/Head/Hats/surgcap_purple.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -441,6 +499,8 @@ - ClothMade - HamsterWearable - WhitelistChameleon + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -454,6 +514,8 @@ sprite: Clothing/Head/Hats/ushanka.rsi - type: AddAccentClothing accent: RussianAccent + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -483,6 +545,8 @@ sprite: DeltaV/Clothing/Head/Hats/warden.rsi # DeltaV - resprite - type: StealTarget stealGroup: ClothingHeadHatWarden + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -494,6 +558,8 @@ sprite: Clothing/Head/Hats/witch.rsi - type: Clothing sprite: Clothing/Head/Hats/witch.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -537,6 +603,8 @@ sprite: Clothing/Head/Hats/xmascrown.rsi - type: Clothing sprite: Clothing/Head/Hats/xmascrown.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -548,6 +616,8 @@ sprite: Clothing/Head/Hats/truckershat.rsi - type: Clothing sprite: Clothing/Head/Hats/truckershat.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -559,6 +629,8 @@ sprite: Clothing/Head/Hats/pyjamasyndicateblack.rsi - type: Clothing sprite: Clothing/Head/Hats/pyjamasyndicateblack.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -570,6 +642,8 @@ sprite: Clothing/Head/Hats/pyjamasyndicatepink.rsi - type: Clothing sprite: Clothing/Head/Hats/pyjamasyndicatepink.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -581,6 +655,8 @@ sprite: Clothing/Head/Hats/pyjamasyndicatered.rsi - type: Clothing sprite: Clothing/Head/Hats/pyjamasyndicatered.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -593,6 +669,8 @@ - type: Clothing sprite: Clothing/Head/Hats/papersack.rsi - type: IdentityBlocker + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -605,6 +683,8 @@ - type: Clothing sprite: Clothing/Head/Hats/papersacksmile.rsi - type: IdentityBlocker + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -616,6 +696,8 @@ sprite: Clothing/Head/Hats/fishcap.rsi - type: Clothing sprite: Clothing/Head/Hats/fishcap.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -632,6 +714,8 @@ - ClothMade - HamsterWearable - WhitelistChameleon + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -643,6 +727,8 @@ sprite: Clothing/Head/Hats/rasta.rsi - type: Clothing sprite: Clothing/Head/Hats/rasta.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -654,6 +740,8 @@ sprite: Clothing/Head/Hats/safarihat.rsi - type: Clothing sprite: Clothing/Head/Hats/safarihat.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -665,6 +753,8 @@ sprite: Clothing/Head/Hats/jester.rsi - type: Clothing sprite: Clothing/Head/Hats/jester.rsi + - type: DropOnSlip + chance: 90 - type: entity parent: ClothingHeadHatJester @@ -674,6 +764,8 @@ sprite: Clothing/Head/Hats/jester2.rsi - type: Clothing sprite: Clothing/Head/Hats/jester2.rsi + - type: DropOnSlip + chance: 90 - type: entity parent: ClothingHeadBase @@ -690,6 +782,8 @@ - ClothMade - HamsterWearable - WhitelistChameleon + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBase @@ -716,6 +810,8 @@ modifiers: coefficients: Blunt: 0.95 + - type: DropOnSlip + chance: 35 - type: entity parent: ClothingHeadBase @@ -929,7 +1025,7 @@ - type: AddAccentClothing accent: ReplacementAccent replacement: cowboy - + - type: entity parent: ClothingHeadHatCowboyBrown id: ClothingHeadHatCowboyBlack @@ -939,7 +1035,7 @@ sprite: Clothing/Head/Hats/cowboyhatblack.rsi - type: Clothing sprite: Clothing/Head/Hats/cowboyhatblack.rsi - + - type: entity parent: ClothingHeadHatCowboyBrown id: ClothingHeadHatCowboyGrey @@ -949,7 +1045,7 @@ sprite: Clothing/Head/Hats/cowboyhatgrey.rsi - type: Clothing sprite: Clothing/Head/Hats/cowboyhatgrey.rsi - + - type: entity parent: ClothingHeadHatCowboyBrown id: ClothingHeadHatCowboyRed @@ -959,7 +1055,7 @@ sprite: Clothing/Head/Hats/cowboyhatred.rsi - type: Clothing sprite: Clothing/Head/Hats/cowboyhatred.rsi - + - type: entity parent: ClothingHeadHatCowboyBrown id: ClothingHeadHatCowboyWhite @@ -969,7 +1065,7 @@ sprite: Clothing/Head/Hats/cowboyhatwhite.rsi - type: Clothing sprite: Clothing/Head/Hats/cowboyhatwhite.rsi - + - type: entity parent: ClothingHeadHatCowboyBrown id: ClothingHeadHatCowboyBountyHunter @@ -978,4 +1074,4 @@ - type: Sprite sprite: Clothing/Head/Hats/cowboyhatbountyhunter.rsi - type: Clothing - sprite: Clothing/Head/Hats/cowboyhatbountyhunter.rsi \ No newline at end of file + sprite: Clothing/Head/Hats/cowboyhatbountyhunter.rsi diff --git a/Resources/Prototypes/Entities/Clothing/Head/misc.yml b/Resources/Prototypes/Entities/Clothing/Head/misc.yml index 9826da57b7..97046cd8b5 100644 --- a/Resources/Prototypes/Entities/Clothing/Head/misc.yml +++ b/Resources/Prototypes/Entities/Clothing/Head/misc.yml @@ -46,6 +46,8 @@ - type: Construction graph: flowercrown node: flowercrown + - type: DropOnSlip + chance: 50 - type: entity parent: ClothingHeadBase @@ -60,6 +62,8 @@ - type: Construction graph: hairflower node: hairflower + - type: DropOnSlip + chance: 60 - type: entity parent: ClothingHeadLightBase @@ -96,6 +100,8 @@ sprite: Clothing/Head/Misc/pwig.rsi - type: Clothing sprite: Clothing/Head/Misc/pwig.rsi + - type: DropOnSlip + chance: 60 - type: entity parent: ClothingHeadBase @@ -137,6 +143,8 @@ tags: - HamsterWearable - WhitelistChameleon + - type: DropOnSlip + chance: 60 - type: entity parent: ClothingHeadBase @@ -151,6 +159,8 @@ - type: PhysicalComposition #you can't just pass up some free plastic! materialComposition: Plastic: 100 + - type: DropOnSlip + chance: 70 - type: entity parent: ClothingHeadBase @@ -183,7 +193,7 @@ sprite: Clothing/Head/Hats/catears.rsi - type: AddAccentClothing accent: OwOAccent - + - type: entity parent: ClothingHeadBase id: ClothingHeadHatDogEars diff --git a/Resources/Prototypes/Entities/Clothing/Head/soft.yml b/Resources/Prototypes/Entities/Clothing/Head/soft.yml index ea5e1c0391..845e53b979 100644 --- a/Resources/Prototypes/Entities/Clothing/Head/soft.yml +++ b/Resources/Prototypes/Entities/Clothing/Head/soft.yml @@ -8,6 +8,8 @@ sprite: Clothing/Head/Soft/bluesoft.rsi - type: Clothing sprite: Clothing/Head/Soft/bluesoft.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBaseButcherable @@ -19,6 +21,8 @@ sprite: Clothing/Head/Soft/bluesoft_flipped.rsi - type: Clothing sprite: Clothing/Head/Soft/bluesoft_flipped.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBaseButcherable @@ -35,6 +39,8 @@ - ClothMade - HamsterWearable - WhitelistChameleon + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBaseButcherable @@ -46,6 +52,8 @@ sprite: Clothing/Head/Soft/cargosoft_flipped.rsi - type: Clothing sprite: Clothing/Head/Soft/cargosoft_flipped.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBaseButcherable @@ -57,6 +65,8 @@ sprite: Clothing/Head/Soft/qmsoft.rsi - type: Clothing sprite: Clothing/Head/Soft/qmsoft.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBaseButcherable @@ -68,6 +78,8 @@ sprite: Clothing/Head/Soft/qmsoft_flipped.rsi - type: Clothing sprite: Clothing/Head/Soft/qmsoft_flipped.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBaseButcherable @@ -79,6 +91,8 @@ sprite: Clothing/Head/Soft/corpsoft.rsi - type: Clothing sprite: Clothing/Head/Soft/corpsoft.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBaseButcherable @@ -90,6 +104,8 @@ sprite: Clothing/Head/Soft/corpsoft_flipped.rsi - type: Clothing sprite: Clothing/Head/Soft/corpsoft_flipped.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBaseButcherable @@ -101,6 +117,8 @@ sprite: Clothing/Head/Soft/greensoft.rsi - type: Clothing sprite: Clothing/Head/Soft/greensoft.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBaseButcherable @@ -112,6 +130,8 @@ sprite: Clothing/Head/Soft/greensoft_flipped.rsi - type: Clothing sprite: Clothing/Head/Soft/greensoft_flipped.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBaseButcherable @@ -123,6 +143,8 @@ sprite: Clothing/Head/Soft/blacksoft.rsi - type: Clothing sprite: Clothing/Head/Soft/blacksoft.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBaseButcherable @@ -134,6 +156,8 @@ sprite: Clothing/Head/Soft/blacksoft_flipped.rsi - type: Clothing sprite: Clothing/Head/Soft/blacksoft_flipped.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBaseButcherable @@ -145,6 +169,8 @@ sprite: Clothing/Head/Soft/greysoft.rsi - type: Clothing sprite: Clothing/Head/Soft/greysoft.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBaseButcherable @@ -156,6 +182,8 @@ sprite: Clothing/Head/Soft/greysoft_flipped.rsi - type: Clothing sprite: Clothing/Head/Soft/greysoft_flipped.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBaseButcherable @@ -167,6 +195,8 @@ sprite: Clothing/Head/Soft/mimesoft.rsi - type: Clothing sprite: Clothing/Head/Soft/mimesoft.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBaseButcherable @@ -178,6 +208,8 @@ sprite: Clothing/Head/Soft/mimesoft_flipped.rsi - type: Clothing sprite: Clothing/Head/Soft/mimesoft_flipped.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBaseButcherable @@ -189,6 +221,8 @@ sprite: Clothing/Head/Soft/orangesoft.rsi - type: Clothing sprite: Clothing/Head/Soft/orangesoft.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBaseButcherable @@ -200,6 +234,8 @@ sprite: Clothing/Head/Soft/orangesoft_flipped.rsi - type: Clothing sprite: Clothing/Head/Soft/orangesoft_flipped.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBaseButcherable @@ -216,6 +252,8 @@ - ClothMade - HamsterWearable - WhitelistChameleon + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBaseButcherable @@ -227,6 +265,8 @@ sprite: Clothing/Head/Soft/purplesoft_flipped.rsi - type: Clothing sprite: Clothing/Head/Soft/purplesoft_flipped.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBaseButcherable @@ -238,6 +278,8 @@ sprite: Clothing/Head/Soft/redsoft.rsi - type: Clothing sprite: Clothing/Head/Soft/redsoft.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBaseButcherable @@ -249,6 +291,8 @@ sprite: Clothing/Head/Soft/redsoft_flipped.rsi - type: Clothing sprite: Clothing/Head/Soft/redsoft_flipped.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBaseButcherable @@ -260,6 +304,8 @@ sprite: Clothing/Head/Soft/secsoft.rsi - type: Clothing sprite: Clothing/Head/Soft/secsoft.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBaseButcherable @@ -271,6 +317,8 @@ sprite: Clothing/Head/Soft/secsoft_flipped.rsi - type: Clothing sprite: Clothing/Head/Soft/secsoft_flipped.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBaseButcherable @@ -282,6 +330,8 @@ sprite: Clothing/Head/Soft/yellowsoft.rsi - type: Clothing sprite: Clothing/Head/Soft/yellowsoft.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBaseButcherable @@ -293,6 +343,8 @@ sprite: Clothing/Head/Soft/yellowsoft_flipped.rsi - type: Clothing sprite: Clothing/Head/Soft/yellowsoft_flipped.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBaseButcherable @@ -304,6 +356,8 @@ sprite: Clothing/Head/Soft/bizarresoft.rsi - type: Clothing sprite: Clothing/Head/Soft/bizarresoft.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBaseButcherable @@ -315,6 +369,8 @@ sprite: Clothing/Head/Soft/bizarresoft_flipped.rsi - type: Clothing sprite: Clothing/Head/Soft/bizarresoft_flipped.rsi + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBaseButcherable @@ -331,6 +387,8 @@ - ClothMade - HamsterWearable - WhitelistChameleon + - type: DropOnSlip + chance: 20 - type: entity parent: ClothingHeadBaseButcherable @@ -342,3 +400,5 @@ sprite: Clothing/Head/Soft/paramedicsoft_flipped.rsi - type: Clothing sprite: Clothing/Head/Soft/paramedicsoft_flipped.rsi + - type: DropOnSlip + chance: 20 diff --git a/Resources/Prototypes/Entities/Clothing/Masks/masks.yml b/Resources/Prototypes/Entities/Clothing/Masks/masks.yml index 77655e7cdb..3710428c3c 100644 --- a/Resources/Prototypes/Entities/Clothing/Masks/masks.yml +++ b/Resources/Prototypes/Entities/Clothing/Masks/masks.yml @@ -195,6 +195,8 @@ tags: - ClownMask - WhitelistChameleon + - type: DropOnSlip + chance: 5 - type: entity parent: ClothingMaskClownBase From 1125c7664720d7889a28a79da614f8cdd2a5ea74 Mon Sep 17 00:00:00 2001 From: Finket <42383212+Finket@users.noreply.github.com> Date: Mon, 26 Feb 2024 06:53:50 +0200 Subject: [PATCH 2/7] Clean up codes from review Co-authored-by: DEATHB4DEFEAT <77995199+DEATHB4DEFEAT@users.noreply.github.com> --- .../Slippery/DropOnSlipComponent.cs | 6 ++++++ .../SimpleStation14/Slippery/DropOnSlipSystem.cs | 15 ++++++++------- .../Prototypes/Entities/Clothing/Head/misc.yml | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Content.Server/SimpleStation14/Slippery/DropOnSlipComponent.cs b/Content.Server/SimpleStation14/Slippery/DropOnSlipComponent.cs index 89ba354c43..4a64bbc130 100644 --- a/Content.Server/SimpleStation14/Slippery/DropOnSlipComponent.cs +++ b/Content.Server/SimpleStation14/Slippery/DropOnSlipComponent.cs @@ -6,10 +6,16 @@ [RegisterComponent] public sealed partial class DropOnSlipComponent : Component { + /// + /// Percent chance to drop this item when slipping + /// [DataField("chance")] [ViewVariables(VVAccess.ReadWrite)] public int Chance = 20; + /// + /// Percent chance to throw the item after successfully rolling to drop it + /// [DataField("chanceToThrow")] [ViewVariables(VVAccess.ReadWrite)] public int ChanceToThrow = 40; diff --git a/Content.Server/SimpleStation14/Slippery/DropOnSlipSystem.cs b/Content.Server/SimpleStation14/Slippery/DropOnSlipSystem.cs index aa1d894dae..7e9cfdcc81 100644 --- a/Content.Server/SimpleStation14/Slippery/DropOnSlipSystem.cs +++ b/Content.Server/SimpleStation14/Slippery/DropOnSlipSystem.cs @@ -22,11 +22,12 @@ public sealed class DropOnSlipSystem : EntitySystem [Dependency] private readonly SharedPhysicsSystem _physics = default!; [Dependency] private readonly ThrowingSystem _throwing = default!; - private static readonly float PocketDropChance = 10f; - private static readonly float PocketThrowChance = 5f; + public const float PocketDropChance = 10f; + public const float PocketThrowChance = 5f; + + public const float ClumsyDropChance = 5f; + public const float ClumsyThrowChance = 90f; - private static readonly float ClumsyDropChance = 5f; - private static readonly float ClumsyThrowChance = 90f; public override void Initialize() { @@ -46,7 +47,7 @@ private void HandleSlip(EntityUid entity, InventoryComponent invComp, ParkSlipEv if (!_invSystem.TryGetSlotEntity(entity, slot.Name, out var item)) continue; - // A check for DropOnSlipComponent. + // Check for DropOnSlipComponent if (slot.Name != "pocket1" && slot.Name != "pocket2" && EntityManager.TryGetComponent(item, out var dropComp) && _random.NextFloat(0, 100) < dropComp.Chance) { var popupString = Loc.GetString("system-drop-on-slip-text-component", ("name", entity), ("item", item)); @@ -55,7 +56,7 @@ private void HandleSlip(EntityUid entity, InventoryComponent invComp, ParkSlipEv continue; } - // A check for any items in pockets. + // Check for any items in pockets if (slot.Name == "pocket1" | slot.Name == "pocket2" && _random.NextFloat(0, 100) < PocketDropChance) { var popupString = Loc.GetString("system-drop-on-slip-text-pocket", ("name", entity), ("item", item)); @@ -64,7 +65,7 @@ private void HandleSlip(EntityUid entity, InventoryComponent invComp, ParkSlipEv continue; } - // A check for ClumsyComponent. + // Check for ClumsyComponent if (slot.Name != "jumpsuit" && _random.NextFloat(0, 100) < ClumsyDropChance && HasComp(entity)) { var popupString = Loc.GetString("system-drop-on-slip-text-clumsy", ("name", entity), ("item", item)); diff --git a/Resources/Prototypes/Entities/Clothing/Head/misc.yml b/Resources/Prototypes/Entities/Clothing/Head/misc.yml index 97046cd8b5..b73d58834a 100644 --- a/Resources/Prototypes/Entities/Clothing/Head/misc.yml +++ b/Resources/Prototypes/Entities/Clothing/Head/misc.yml @@ -193,7 +193,7 @@ sprite: Clothing/Head/Hats/catears.rsi - type: AddAccentClothing accent: OwOAccent - + - type: entity parent: ClothingHeadBase id: ClothingHeadHatDogEars From fa2071a309b646aba1d9165016f257b1e4a3ab9c Mon Sep 17 00:00:00 2001 From: Finket Date: Mon, 26 Feb 2024 11:26:16 +0200 Subject: [PATCH 3/7] Remove unused variable --- .../SimpleStation14/Slippery/DropOnSlipComponent.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Content.Server/SimpleStation14/Slippery/DropOnSlipComponent.cs b/Content.Server/SimpleStation14/Slippery/DropOnSlipComponent.cs index 4a64bbc130..10766fa9e6 100644 --- a/Content.Server/SimpleStation14/Slippery/DropOnSlipComponent.cs +++ b/Content.Server/SimpleStation14/Slippery/DropOnSlipComponent.cs @@ -12,11 +12,4 @@ public sealed partial class DropOnSlipComponent : Component [DataField("chance")] [ViewVariables(VVAccess.ReadWrite)] public int Chance = 20; - - /// - /// Percent chance to throw the item after successfully rolling to drop it - /// - [DataField("chanceToThrow")] - [ViewVariables(VVAccess.ReadWrite)] - public int ChanceToThrow = 40; } From e0443a99974b647f5ac22e36f990fe7f17fab29b Mon Sep 17 00:00:00 2001 From: Finket Date: Mon, 18 Mar 2024 16:49:32 +0200 Subject: [PATCH 4/7] Move from SimpleStation14 to Parkstation namespaces --- .../Slippery/DropOnSlipComponent.cs | 2 +- .../Slippery/DropOnSlipSystem.cs | 14 +++++++------- .../Content/Slippery/dropOnSlip.ftl | 0 3 files changed, 8 insertions(+), 8 deletions(-) rename Content.Server/{SimpleStation14 => Parkstation}/Slippery/DropOnSlipComponent.cs (87%) rename Content.Server/{SimpleStation14 => Parkstation}/Slippery/DropOnSlipSystem.cs (94%) rename Resources/Locale/en-US/{simplestation14 => parkstation}/Content/Slippery/dropOnSlip.ftl (100%) diff --git a/Content.Server/SimpleStation14/Slippery/DropOnSlipComponent.cs b/Content.Server/Parkstation/Slippery/DropOnSlipComponent.cs similarity index 87% rename from Content.Server/SimpleStation14/Slippery/DropOnSlipComponent.cs rename to Content.Server/Parkstation/Slippery/DropOnSlipComponent.cs index 10766fa9e6..7b7b533959 100644 --- a/Content.Server/SimpleStation14/Slippery/DropOnSlipComponent.cs +++ b/Content.Server/Parkstation/Slippery/DropOnSlipComponent.cs @@ -1,4 +1,4 @@ -namespace Content.Server.SimpleStation14.Slippery; +namespace Content.Server.Parkstation.Slippery; /// /// Uses provided chance to try and drop the item when slipped, if equipped. diff --git a/Content.Server/SimpleStation14/Slippery/DropOnSlipSystem.cs b/Content.Server/Parkstation/Slippery/DropOnSlipSystem.cs similarity index 94% rename from Content.Server/SimpleStation14/Slippery/DropOnSlipSystem.cs rename to Content.Server/Parkstation/Slippery/DropOnSlipSystem.cs index 7e9cfdcc81..4a9610a91d 100644 --- a/Content.Server/SimpleStation14/Slippery/DropOnSlipSystem.cs +++ b/Content.Server/Parkstation/Slippery/DropOnSlipSystem.cs @@ -1,17 +1,17 @@ using System.Numerics; +using Content.Server.Popups; using Content.Shared.Administration.Logs; using Content.Shared.Database; +using Content.Shared.Interaction.Components; using Content.Shared.Inventory; -using Robust.Shared.Random; -using Content.Server.Popups; using Content.Shared.Popups; using Content.Shared.Slippery; -using Content.Shared.Interaction.Components; -using Robust.Shared.Physics.Systems; -using Robust.Shared.Physics.Components; using Content.Shared.Throwing; +using Robust.Shared.Physics.Components; +using Robust.Shared.Physics.Systems; +using Robust.Shared.Random; -namespace Content.Server.SimpleStation14.Slippery; +namespace Content.Server.Parkstation.Slippery; public sealed class DropOnSlipSystem : EntitySystem { @@ -48,7 +48,7 @@ private void HandleSlip(EntityUid entity, InventoryComponent invComp, ParkSlipEv continue; // Check for DropOnSlipComponent - if (slot.Name != "pocket1" && slot.Name != "pocket2" && EntityManager.TryGetComponent(item, out var dropComp) && _random.NextFloat(0, 100) < dropComp.Chance) + if (slot.Name != "pocket1" && slot.Name != "pocket2" && EntityManager.TryGetComponent(item, out var dropComp) && _random.NextFloat(0, 100) < dropComp.Chance) { var popupString = Loc.GetString("system-drop-on-slip-text-component", ("name", entity), ("item", item)); diff --git a/Resources/Locale/en-US/simplestation14/Content/Slippery/dropOnSlip.ftl b/Resources/Locale/en-US/parkstation/Content/Slippery/dropOnSlip.ftl similarity index 100% rename from Resources/Locale/en-US/simplestation14/Content/Slippery/dropOnSlip.ftl rename to Resources/Locale/en-US/parkstation/Content/Slippery/dropOnSlip.ftl From bd7f5184783952c827a27fbe672c7c532760073b Mon Sep 17 00:00:00 2001 From: Finket Date: Mon, 18 Mar 2024 16:56:28 +0200 Subject: [PATCH 5/7] Fix variables --- .../Parkstation/Slippery/DropOnSlipSystem.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Content.Server/Parkstation/Slippery/DropOnSlipSystem.cs b/Content.Server/Parkstation/Slippery/DropOnSlipSystem.cs index 4a9610a91d..e2c1f554c0 100644 --- a/Content.Server/Parkstation/Slippery/DropOnSlipSystem.cs +++ b/Content.Server/Parkstation/Slippery/DropOnSlipSystem.cs @@ -18,15 +18,15 @@ public sealed class DropOnSlipSystem : EntitySystem [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!; [Dependency] private readonly PopupSystem _popup = default!; [Dependency] private readonly IRobustRandom _random = default!; - [Dependency] private readonly InventorySystem _invSystem = default!; + [Dependency] private readonly InventorySystem _inventory = default!; [Dependency] private readonly SharedPhysicsSystem _physics = default!; [Dependency] private readonly ThrowingSystem _throwing = default!; - public const float PocketDropChance = 10f; - public const float PocketThrowChance = 5f; + public float PocketDropChance = 10f; + public float PocketThrowChance = 5f; - public const float ClumsyDropChance = 5f; - public const float ClumsyThrowChance = 90f; + public float ClumsyDropChance = 5f; + public float ClumsyThrowChance = 90f; public override void Initialize() @@ -39,12 +39,12 @@ public override void Initialize() private void HandleSlip(EntityUid entity, InventoryComponent invComp, ParkSlipEvent args) { - if (!_invSystem.TryGetSlots(entity, out var slotDefinitions)) + if (!_inventory.TryGetSlots(entity, out var slotDefinitions)) return; foreach (var slot in slotDefinitions) { - if (!_invSystem.TryGetSlotEntity(entity, slot.Name, out var item)) + if (!_inventory.TryGetSlotEntity(entity, slot.Name, out var item)) continue; // Check for DropOnSlipComponent @@ -78,7 +78,7 @@ private void HandleSlip(EntityUid entity, InventoryComponent invComp, ParkSlipEv private void Drop(EntityUid entity, EntityUid item, string slot, string popupString) { - if (!_invSystem.TryUnequip(entity, slot, false, true)) + if (!_inventory.TryUnequip(entity, slot, false, true)) return; EntityManager.TryGetComponent(entity, out var entPhysComp); From e197e49a532f1fc0b665b054e2c257e538202651 Mon Sep 17 00:00:00 2001 From: Finket Date: Sat, 27 Apr 2024 13:21:27 +0300 Subject: [PATCH 6/7] Refactor DropOnSlipSystem --- .../Slippery/DropOnSlipComponent.cs | 2 +- .../Parkstation/Slippery/DropOnSlipSystem.cs | 33 +++++++++---------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/Content.Server/Parkstation/Slippery/DropOnSlipComponent.cs b/Content.Server/Parkstation/Slippery/DropOnSlipComponent.cs index 7b7b533959..18b9191e0c 100644 --- a/Content.Server/Parkstation/Slippery/DropOnSlipComponent.cs +++ b/Content.Server/Parkstation/Slippery/DropOnSlipComponent.cs @@ -1,7 +1,7 @@ namespace Content.Server.Parkstation.Slippery; /// -/// Uses provided chance to try and drop the item when slipped, if equipped. +/// Marks this item as one that may be dropped when its wearer slips with it equipped. /// [RegisterComponent] public sealed partial class DropOnSlipComponent : Component diff --git a/Content.Server/Parkstation/Slippery/DropOnSlipSystem.cs b/Content.Server/Parkstation/Slippery/DropOnSlipSystem.cs index e2c1f554c0..88f77aeb61 100644 --- a/Content.Server/Parkstation/Slippery/DropOnSlipSystem.cs +++ b/Content.Server/Parkstation/Slippery/DropOnSlipSystem.cs @@ -47,33 +47,30 @@ private void HandleSlip(EntityUid entity, InventoryComponent invComp, ParkSlipEv if (!_inventory.TryGetSlotEntity(entity, slot.Name, out var item)) continue; - // Check for DropOnSlipComponent - if (slot.Name != "pocket1" && slot.Name != "pocket2" && EntityManager.TryGetComponent(item, out var dropComp) && _random.NextFloat(0, 100) < dropComp.Chance) + if (ShouldBeDropped(entity, slot, item)) { var popupString = Loc.GetString("system-drop-on-slip-text-component", ("name", entity), ("item", item)); Drop(entity, item.Value, slot.Name, popupString); - continue; } + } + } - // Check for any items in pockets - if (slot.Name == "pocket1" | slot.Name == "pocket2" && _random.NextFloat(0, 100) < PocketDropChance) - { - var popupString = Loc.GetString("system-drop-on-slip-text-pocket", ("name", entity), ("item", item)); + private bool ShouldBeDropped(EntityUid entity, SlotDefinition slot, EntityUid? item) + { + // Check for any items in pockets or other criteria + if (slot.SlotFlags == SlotFlags.POCKET && _random.NextFloat(0, 100) < PocketDropChance) + return true; - Drop(entity, item.Value, slot.Name, popupString); - continue; - } + // Check for DropOnSlipComponent + if (EntityManager.TryGetComponent(item, out var dropComp) && _random.NextFloat(0, 100) < dropComp.Chance) + return true; - // Check for ClumsyComponent - if (slot.Name != "jumpsuit" && _random.NextFloat(0, 100) < ClumsyDropChance && HasComp(entity)) - { - var popupString = Loc.GetString("system-drop-on-slip-text-clumsy", ("name", entity), ("item", item)); + // Check for ClumsyComponent + if (slot.Name != "jumpsuit" && _random.NextFloat(0, 100) < ClumsyDropChance && HasComp(entity)) + return true; - Drop(entity, item.Value, slot.Name, popupString); - continue; - } - } + return false; } private void Drop(EntityUid entity, EntityUid item, string slot, string popupString) From f9bfddde4e16409ce0a7b1239b47fd634a25eb86 Mon Sep 17 00:00:00 2001 From: DEATHB4DEFEAT Date: Mon, 19 Aug 2024 15:03:36 -0700 Subject: [PATCH 7/7] fix test --- Resources/Prototypes/Entities/Clothing/Head/soft.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Resources/Prototypes/Entities/Clothing/Head/soft.yml b/Resources/Prototypes/Entities/Clothing/Head/soft.yml index 92c9cf62b7..22c9c622ea 100644 --- a/Resources/Prototypes/Entities/Clothing/Head/soft.yml +++ b/Resources/Prototypes/Entities/Clothing/Head/soft.yml @@ -90,10 +90,6 @@ - ClothMade - HamsterWearable - WhitelistChameleon - - type: Sprite - sprite: Clothing/Head/Soft/cargosoft_flipped.rsi - - type: Clothing - sprite: Clothing/Head/Soft/cargosoft_flipped.rsi - type: DropOnSlip chance: 20