Nerf bible (#10023)

This commit is contained in:
metalgearsloth
2022-09-17 00:27:05 +10:00
committed by GitHub
parent d50af6e67d
commit 4df4238c4c
4 changed files with 58 additions and 38 deletions

View File

@@ -1,12 +1,10 @@
using Content.Shared.Interaction;
using Content.Shared.Inventory;
using Content.Shared.MobState.Components;
using Content.Shared.MobState;
using Content.Shared.Damage;
using Content.Shared.Verbs;
using Content.Shared.ActionBlocker;
using Content.Shared.Actions;
using Content.Server.Cooldown;
using Content.Server.Bible.Components;
using Content.Server.MobState;
using Content.Server.Popups;
@@ -14,23 +12,23 @@ using Content.Server.Ghost.Roles.Components;
using Content.Server.Ghost.Roles.Events;
using Content.Shared.IdentityManagement;
using Content.Shared.Popups;
using Content.Shared.Timing;
using Robust.Shared.Random;
using Robust.Shared.Audio;
using Robust.Shared.Player;
using Robust.Shared.Timing;
namespace Content.Server.Bible
{
public sealed class BibleSystem : EntitySystem
{
[Dependency] private readonly InventorySystem _invSystem = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly ActionBlockerSystem _blocker = default!;
[Dependency] private readonly SharedActionsSystem _actionsSystem = default!;
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
[Dependency] private readonly InventorySystem _invSystem = default!;
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly SharedActionsSystem _actionsSystem = default!;
[Dependency] private readonly UseDelaySystem _delay = default!;
public override void Initialize()
{
@@ -94,28 +92,23 @@ namespace Content.Server.Bible
if (!args.CanReach)
return;
var currentTime = _gameTiming.CurTime;
UseDelayComponent? delay = null;
if (currentTime < component.CooldownEnd)
{
if (_delay.ActiveDelay(uid, delay))
return;
}
if (args.Target == null || args.Target == args.User || !_mobStateSystem.IsAlive(args.Target.Value))
{
return;
}
component.LastAttackTime = currentTime;
component.CooldownEnd = component.LastAttackTime + TimeSpan.FromSeconds(component.CooldownTime);
RaiseLocalEvent(uid, new RefreshItemCooldownEvent(component.LastAttackTime, component.CooldownEnd), false);
if (!HasComp<BibleUserComponent>(args.User))
{
_popupSystem.PopupEntity(Loc.GetString("bible-sizzle"), args.User, Filter.Entities(args.User));
SoundSystem.Play(component.SizzleSoundPath.GetSound(), Filter.Pvs(args.User), args.User);
_damageableSystem.TryChangeDamage(args.User, component.DamageOnUntrainedUse, true);
_delay.BeginDelay(uid, delay);
return;
}
@@ -133,18 +126,31 @@ namespace Content.Server.Bible
SoundSystem.Play("/Audio/Effects/hit_kick.ogg", Filter.Pvs(args.Target.Value), args.User);
_damageableSystem.TryChangeDamage(args.Target.Value, component.DamageOnFail, true);
_delay.BeginDelay(uid, delay);
return;
}
}
var othersMessage = Loc.GetString(component.LocPrefix + "-heal-success-others", ("user", Identity.Entity(args.User, EntityManager)),("target", Identity.Entity(args.Target.Value, EntityManager)),("bible", uid));
_popupSystem.PopupEntity(othersMessage, args.User, Filter.PvsExcept(args.User), PopupType.Medium);
var damage = _damageableSystem.TryChangeDamage(args.Target.Value, component.Damage, true);
var selfMessage = Loc.GetString(component.LocPrefix + "-heal-success-self", ("target", Identity.Entity(args.Target.Value, EntityManager)),("bible", uid));
_popupSystem.PopupEntity(selfMessage, args.User, Filter.Entities(args.User), PopupType.Large);
if (damage == null || damage.Total == 0)
{
var othersMessage = Loc.GetString(component.LocPrefix + "-heal-success-none-others", ("user", Identity.Entity(args.User, EntityManager)),("target", Identity.Entity(args.Target.Value, EntityManager)),("bible", uid));
_popupSystem.PopupEntity(othersMessage, args.User, Filter.PvsExcept(args.User), PopupType.Medium);
SoundSystem.Play(component.HealSoundPath.GetSound(), Filter.Pvs(args.Target.Value), args.User);
_damageableSystem.TryChangeDamage(args.Target.Value, component.Damage, true);
var selfMessage = Loc.GetString(component.LocPrefix + "-heal-success-none-self", ("target", Identity.Entity(args.Target.Value, EntityManager)),("bible", uid));
_popupSystem.PopupEntity(selfMessage, args.User, Filter.Entities(args.User), PopupType.Large);
}
else
{
var othersMessage = Loc.GetString(component.LocPrefix + "-heal-success-others", ("user", Identity.Entity(args.User, EntityManager)),("target", Identity.Entity(args.Target.Value, EntityManager)),("bible", uid));
_popupSystem.PopupEntity(othersMessage, args.User, Filter.PvsExcept(args.User), PopupType.Medium);
var selfMessage = Loc.GetString(component.LocPrefix + "-heal-success-self", ("target", Identity.Entity(args.Target.Value, EntityManager)),("bible", uid));
_popupSystem.PopupEntity(selfMessage, args.User, Filter.Entities(args.User), PopupType.Large);
SoundSystem.Play(component.HealSoundPath.GetSound(), Filter.Pvs(args.Target.Value), args.User);
_delay.BeginDelay(uid, delay);
}
}
private void AddSummonVerb(EntityUid uid, SummonableComponent component, GetVerbsEvent<AlternativeVerb> args)
@@ -238,5 +244,7 @@ namespace Content.Server.Bible
}
public sealed class SummonActionEvent : InstantActionEvent
{}
{
}
}

View File

@@ -6,29 +6,34 @@ namespace Content.Server.Bible.Components
[RegisterComponent]
public sealed class BibleComponent : Component
{
// Damage that will be healed on a success
/// <summary>
/// Damage that will be healed on a success
/// </summary>
[DataField("damage", required: true)]
[ViewVariables(VVAccess.ReadWrite)]
public DamageSpecifier Damage = default!;
// Damage that will be dealt on a failure
/// <summary>
/// Damage that will be dealt on a failure
/// </summary>
[DataField("damageOnFail", required: true)]
[ViewVariables(VVAccess.ReadWrite)]
public DamageSpecifier DamageOnFail = default!;
// Damage that will be dealt when a non-chaplain attempts to heal
/// <summary>
/// Damage that will be dealt when a non-chaplain attempts to heal
/// </summary>
[DataField("damageOnUntrainedUse", required: true)]
[ViewVariables(VVAccess.ReadWrite)]
public DamageSpecifier DamageOnUntrainedUse = default!;
//Chance the bible will fail to heal someone with no helmet
/// <summary>
/// Chance the bible will fail to heal someone with no helmet
/// </summary>
[DataField("failChance")]
[ViewVariables(VVAccess.ReadWrite)]
public float FailChance = 0.34f;
public TimeSpan LastAttackTime;
public TimeSpan CooldownEnd;
[DataField("cooldownTime")]
public float CooldownTime { get; } = 5f;
[DataField("sizzleSound")]
public SoundSpecifier SizzleSoundPath = new SoundPathSpecifier("/Audio/Effects/lightburn.ogg");
[DataField("healSound")]