Fix clown not being clumsy (#5208)

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
Ephememory
2022-02-16 08:24:38 -06:00
committed by GitHub
parent 6b7919678e
commit 8b1a711843
6 changed files with 36 additions and 17 deletions

View File

@@ -1,3 +1,4 @@
using Content.Shared.Damage;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Random; using Robust.Shared.Random;
@@ -12,6 +13,9 @@ namespace Content.Server.Interaction.Components
{ {
[Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly IRobustRandom _random = default!;
[DataField("clumsyDamage", required: true)]
[ViewVariables(VVAccess.ReadWrite)]
public DamageSpecifier ClumsyDamage = default!;
public bool RollClumsy(float chance) public bool RollClumsy(float chance)
{ {
return Running && _random.Prob(chance); return Running && _random.Prob(chance);

View File

@@ -1,25 +1,35 @@
using Content.Shared.Roles; using Content.Shared.Roles;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Shared.GameObjects; using Robust.Shared.Prototypes;
using Robust.Shared.IoC; using Robust.Shared.Serialization.Manager;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Jobs namespace Content.Server.Jobs
{ {
[UsedImplicitly] [UsedImplicitly]
public sealed class AddComponentSpecial : JobSpecial public sealed class AddComponentSpecial : JobSpecial
{ {
// TODO: Type serializer that ensures the component exists.
[DataField("component", required:true)] [DataField("components")]
public string Component { get; } = string.Empty; [AlwaysPushInheritance]
public EntityPrototype.ComponentRegistry Components { get; } = new();
public override void AfterEquip(EntityUid mob) public override void AfterEquip(EntityUid mob)
{ {
// Yes, this will throw if your component is invalid. // now its a registry of components, still throws i bet.
var component = (Component)IoCManager.Resolve<IComponentFactory>().GetComponent(Component); // TODO: This is hot garbage and probably needs an engine change to not be a POS.
component.Owner = mob; var factory = IoCManager.Resolve<IComponentFactory>();
var entityManager = IoCManager.Resolve<IEntityManager>();
var serializationManager = IoCManager.Resolve<ISerializationManager>();
IoCManager.Resolve<IEntityManager>().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);
}
} }
} }
} }

View File

@@ -56,10 +56,10 @@ public sealed partial class GunSystem
gun.LastFireTime = curTime; gun.LastFireTime = curTime;
var coordinates = Transform(gun.Owner).Coordinates; var coordinates = Transform(gun.Owner).Coordinates;
if (gun.ClumsyCheck && gun.ClumsyDamage != null && ClumsyComponent.TryRollClumsy(user, gun.ClumsyExplodeChance)) if (gun.ClumsyCheck && EntityManager.TryGetComponent<ClumsyComponent>(user, out var clumsyComponent) && ClumsyComponent.TryRollClumsy(user, gun.ClumsyExplodeChance))
{ {
//Wound them //Wound them
_damageable.TryChangeDamage(user, gun.ClumsyDamage); _damageable.TryChangeDamage(user, clumsyComponent.ClumsyDamage);
_stun.TryParalyze(user, TimeSpan.FromSeconds(3f), true); _stun.TryParalyze(user, TimeSpan.FromSeconds(3f), true);
// Apply salt to the wound ("Honk!") // Apply salt to the wound ("Honk!")

View File

@@ -31,8 +31,5 @@ namespace Content.Server.Weapon.Ranged
[DataField("clumsyWeaponShotSound")] [DataField("clumsyWeaponShotSound")]
public SoundSpecifier ClumsyWeaponShotSound = new SoundPathSpecifier("/Audio/Weapons/Guns/Gunshots/bang.ogg"); public SoundSpecifier ClumsyWeaponShotSound = new SoundPathSpecifier("/Audio/Weapons/Guns/Gunshots/bang.ogg");
[ViewVariables(VVAccess.ReadWrite)]
[DataField("clumsyDamage")]
public DamageSpecifier? ClumsyDamage;
} }
} }

View File

@@ -11,7 +11,8 @@
- Maintenance - Maintenance
special: special:
- !type:AddComponentSpecial - !type:AddComponentSpecial
component: BibleUser #Lets them heal with bibles components:
- type: BibleUser #Lets them heal with bibles
- type: startingGear - type: startingGear
id: ChaplainGear id: ChaplainGear

View File

@@ -11,7 +11,14 @@
- Maintenance - Maintenance
special: special:
- !type:AddComponentSpecial - !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 - type: startingGear
id: ClownGear id: ClownGear