Toy Box filled with toys (ready for merge) (#16252)

This commit is contained in:
brainfood1183
2023-06-03 04:31:47 +01:00
committed by GitHub
parent 3d29ab3486
commit c99585c94f
75 changed files with 1118 additions and 13 deletions

View File

@@ -0,0 +1,40 @@
using Content.Shared.Damage;
using Robust.Shared.Audio;
namespace Content.Server.Weapons.Melee.WeaponRandom;
[RegisterComponent]
internal sealed class WeaponRandomComponent : Component
{
/// <summary>
/// Amount of damage that will be caused. This is specified in the yaml.
/// </summary>
[DataField("damageBonus")]
public DamageSpecifier DamageBonus = new();
/// <summary>
/// Chance for the damage bonus to occur.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
public float RandomDamageChance = 0.00001f;
/// <summary>
/// If this is true then the random damage will occur.
/// </summary>
[DataField("randomDamage")]
public bool RandomDamage = true;
/// <summary>
/// If this is true then the weapon will have a unique interaction with cluwnes.
/// </summary>
[DataField("antiCluwne")]
public bool AntiCluwne = true;
/// <summary>
/// Noise to play when the damage bonus occurs.
/// </summary>
[DataField("damageSound")]
public SoundSpecifier DamageSound = new SoundPathSpecifier("/Audio/Items/bikehorn.ogg");
}

View File

@@ -0,0 +1,36 @@
using Content.Shared.Weapons.Melee.Events;
using Robust.Shared.Random;
using Content.Shared.Cluwne;
namespace Content.Server.Weapons.Melee.WeaponRandom;
public sealed class WeaponRandomSystem : EntitySystem
{
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<WeaponRandomComponent, MeleeHitEvent>(OnMeleeHit);
}
private void OnMeleeHit(EntityUid uid, WeaponRandomComponent component, MeleeHitEvent args)
{
foreach (var entity in args.HitEntities)
{
if (HasComp<CluwneComponent>(entity) && component.AntiCluwne)
{
_audio.PlayPvs(component.DamageSound, uid);
args.BonusDamage = component.DamageBonus;
}
else if (_random.Prob(component.RandomDamageChance) && component.RandomDamage)
{
_audio.PlayPvs(component.DamageSound, uid);
args.BonusDamage = component.DamageBonus;
}
}
}
}