From 8b1a7118435cd2390027c80258a62be00ed4acc4 Mon Sep 17 00:00:00 2001 From: Ephememory <66768086+Ephememory@users.noreply.github.com> Date: Wed, 16 Feb 2022 08:24:38 -0600 Subject: [PATCH] Fix clown not being clumsy (#5208) Co-authored-by: metalgearsloth --- .../Interaction/Components/ClumsyComponent.cs | 4 +++ Content.Server/Jobs/AddComponentSpecial.cs | 30 ++++++++++++------- .../Weapon/Ranged/GunSystem.Guns.cs | 4 +-- .../Ranged/ServerRangedWeaponComponent.cs | 3 -- .../Roles/Jobs/Civilian/chaplain.yml | 3 +- .../Prototypes/Roles/Jobs/Civilian/clown.yml | 9 +++++- 6 files changed, 36 insertions(+), 17 deletions(-) diff --git a/Content.Server/Interaction/Components/ClumsyComponent.cs b/Content.Server/Interaction/Components/ClumsyComponent.cs index f64f74e9f3..4dd68dd831 100644 --- a/Content.Server/Interaction/Components/ClumsyComponent.cs +++ b/Content.Server/Interaction/Components/ClumsyComponent.cs @@ -1,3 +1,4 @@ +using Content.Shared.Damage; using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Random; @@ -12,6 +13,9 @@ namespace Content.Server.Interaction.Components { [Dependency] private readonly IRobustRandom _random = default!; + [DataField("clumsyDamage", required: true)] + [ViewVariables(VVAccess.ReadWrite)] + public DamageSpecifier ClumsyDamage = default!; public bool RollClumsy(float chance) { return Running && _random.Prob(chance); diff --git a/Content.Server/Jobs/AddComponentSpecial.cs b/Content.Server/Jobs/AddComponentSpecial.cs index b154a52c80..627b900087 100644 --- a/Content.Server/Jobs/AddComponentSpecial.cs +++ b/Content.Server/Jobs/AddComponentSpecial.cs @@ -1,25 +1,35 @@ using Content.Shared.Roles; using JetBrains.Annotations; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; -using Robust.Shared.Serialization.Manager.Attributes; +using Robust.Shared.Prototypes; +using Robust.Shared.Serialization.Manager; namespace Content.Server.Jobs { [UsedImplicitly] public sealed class AddComponentSpecial : JobSpecial { - // TODO: Type serializer that ensures the component exists. - [DataField("component", required:true)] - public string Component { get; } = string.Empty; + + [DataField("components")] + [AlwaysPushInheritance] + public EntityPrototype.ComponentRegistry Components { get; } = new(); public override void AfterEquip(EntityUid mob) { - // Yes, this will throw if your component is invalid. - var component = (Component)IoCManager.Resolve().GetComponent(Component); - component.Owner = mob; + // now its a registry of components, still throws i bet. + // TODO: This is hot garbage and probably needs an engine change to not be a POS. + var factory = IoCManager.Resolve(); + var entityManager = IoCManager.Resolve(); + var serializationManager = IoCManager.Resolve(); - IoCManager.Resolve().AddComponent(mob, component); + foreach (var (name, data) in Components) + { + var component = (Component) factory.GetComponent(name); + component.Owner = mob; + + var copied = (Component?) serializationManager.Copy(data, component, null); + if (copied != null) + entityManager.AddComponent(mob, copied); + } } } } diff --git a/Content.Server/Weapon/Ranged/GunSystem.Guns.cs b/Content.Server/Weapon/Ranged/GunSystem.Guns.cs index 7eac43dfaf..6f6f2d3781 100644 --- a/Content.Server/Weapon/Ranged/GunSystem.Guns.cs +++ b/Content.Server/Weapon/Ranged/GunSystem.Guns.cs @@ -56,10 +56,10 @@ public sealed partial class GunSystem gun.LastFireTime = curTime; var coordinates = Transform(gun.Owner).Coordinates; - if (gun.ClumsyCheck && gun.ClumsyDamage != null && ClumsyComponent.TryRollClumsy(user, gun.ClumsyExplodeChance)) + if (gun.ClumsyCheck && EntityManager.TryGetComponent(user, out var clumsyComponent) && ClumsyComponent.TryRollClumsy(user, gun.ClumsyExplodeChance)) { //Wound them - _damageable.TryChangeDamage(user, gun.ClumsyDamage); + _damageable.TryChangeDamage(user, clumsyComponent.ClumsyDamage); _stun.TryParalyze(user, TimeSpan.FromSeconds(3f), true); // Apply salt to the wound ("Honk!") diff --git a/Content.Server/Weapon/Ranged/ServerRangedWeaponComponent.cs b/Content.Server/Weapon/Ranged/ServerRangedWeaponComponent.cs index 9b18038976..ce48beca45 100644 --- a/Content.Server/Weapon/Ranged/ServerRangedWeaponComponent.cs +++ b/Content.Server/Weapon/Ranged/ServerRangedWeaponComponent.cs @@ -31,8 +31,5 @@ namespace Content.Server.Weapon.Ranged [DataField("clumsyWeaponShotSound")] public SoundSpecifier ClumsyWeaponShotSound = new SoundPathSpecifier("/Audio/Weapons/Guns/Gunshots/bang.ogg"); - [ViewVariables(VVAccess.ReadWrite)] - [DataField("clumsyDamage")] - public DamageSpecifier? ClumsyDamage; } } diff --git a/Resources/Prototypes/Roles/Jobs/Civilian/chaplain.yml b/Resources/Prototypes/Roles/Jobs/Civilian/chaplain.yml index 26c648e41e..e4de92c71b 100644 --- a/Resources/Prototypes/Roles/Jobs/Civilian/chaplain.yml +++ b/Resources/Prototypes/Roles/Jobs/Civilian/chaplain.yml @@ -11,7 +11,8 @@ - Maintenance special: - !type:AddComponentSpecial - component: BibleUser #Lets them heal with bibles + components: + - type: BibleUser #Lets them heal with bibles - type: startingGear id: ChaplainGear diff --git a/Resources/Prototypes/Roles/Jobs/Civilian/clown.yml b/Resources/Prototypes/Roles/Jobs/Civilian/clown.yml index a9c532a84e..bcfcbfd0b8 100644 --- a/Resources/Prototypes/Roles/Jobs/Civilian/clown.yml +++ b/Resources/Prototypes/Roles/Jobs/Civilian/clown.yml @@ -11,7 +11,14 @@ - Maintenance special: - !type:AddComponentSpecial - component: Clumsy # Adds ClumsyComponent to the mob. + components: + - type: Clumsy + clumsyDamage: + types: #literally just picked semi random valus. i tested this once and tweaked it. + Blunt: 5 + Piercing: 4 + groups: + Burn: 3 - type: startingGear id: ClownGear