mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-23 16:48:10 +03:00
<!-- This is a semi-strict format, you can add/remove sections as needed but the order/format should be kept the same Remove these comments before submitting --> # Description <!-- Explain this PR in as much detail as applicable Some example prompts to consider: How might this affect the game? The codebase? What might be some alternatives to this? How/Who does this benefit/hurt [the game/codebase]? --> With protection against flashes a bit more easily obtainable than before (welding masks, sunglasses, engineering goggles, cyber eye traits, etc.) and having thought about this idea before, I'd like to do a quick poll on an idea I've had and would be willing to implement: Instead of a Flash, give HeadRevolutionaries a Manifesto. They use this (with a short doafter) on a person to convert them, spouting Rev Ideology at them as the doafter runs. This will only be blockable by * Mindshields * Not being an intelligent creature As a side-effect, Epistemics won't necessarily be the Prime First Target to Rev anymore. Unless they want more books and they're in the library. A head revolutionary will spawn with this book. It may also be found in maintenance or bookshelves, though this is not common. This is to ensure that _having_ the book does not immediately out you as a revolutionary. The book has no charges, as opposed to flashes. This is balanced out by the fact that you audibly spout revolutionary ideology and propaganda at a target and that it takes a few seconds to do the conversion. --- <!-- This is default collapsed, readers click to expand it and see all your media The PR media section can get very large at times, so this is a good way to keep it clean The title is written using HTML tags The title must be within the <summary> tags or you won't see it --> <details><summary><h1>Media</h1></summary> <p> https://github.com/user-attachments/assets/089d707b-9178-45b1-a38a-99f06ae5d9b1 </p> </details> --- # Changelog <!-- You can add an author after the `🆑` to change the name that appears in the changelog (ex: `🆑 Death`) Leaving it blank will default to your GitHub display name This includes all available types for the changelog --> 🆑 - tweak: Changed the way Revolutionaries convert people. Instead of flashes, they now use the Revolutionary Manifesto to 'persuade' new conspirators. This has a small delay (three seconds) and will make you speak propaganda at the target. Note that the book itself is not contraband, and may also be found in other places. Only a Head Revolutionary will be able to make use of its persuasive power, however... <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a new in-game item—the Revolutionary Manifesto—which replaces previous flash-based conversion tools. It features distinctive visual design and sound effects. - Added a new method for sending in-game chat messages to all users, enhancing communication capabilities. - **Gameplay Updates** - Head Revolutionary roles now convert others using the manifesto, with updated narrative text, motivational speeches, and revised starting gear. - **Communication Enhancements** - Improved in-game messaging systems streamline chat interactions for a smoother experience. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Timfa <timfalken@hotmail.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: VMSolidus <evilexecutive@gmail.com> (cherry picked from commit 4f4c5be744332ba03245de0a5da8fd36255855f5)
299 lines
12 KiB
C#
299 lines
12 KiB
C#
using System.Linq;
|
|
using Content.Server._White.Flash;
|
|
using Content.Server._White.Hearing;
|
|
using Content.Server.Flash.Components;
|
|
using Content.Shared.Flash.Components;
|
|
using Content.Server.Light.EntitySystems;
|
|
using Content.Server.Popups;
|
|
using Content.Server.Stunnable;
|
|
using Content.Shared.Charges.Components;
|
|
using Content.Shared.Charges.Systems;
|
|
using Content.Shared.Eye.Blinding.Components;
|
|
using Content.Shared.Flash;
|
|
using Content.Shared.IdentityManagement;
|
|
using Content.Shared.Interaction;
|
|
using Content.Shared.Interaction.Events;
|
|
using Content.Shared.Inventory;
|
|
using Content.Shared.Physics;
|
|
using Content.Shared.Tag;
|
|
using Content.Shared.Throwing;
|
|
using Content.Shared.Weapons.Melee.Events;
|
|
using Robust.Server.Audio;
|
|
using Robust.Server.GameObjects;
|
|
using Robust.Shared.Audio;
|
|
using Robust.Shared.Random;
|
|
using Robust.Shared.Timing;
|
|
using InventoryComponent = Content.Shared.Inventory.InventoryComponent;
|
|
using Content.Shared.Traits.Assorted.Components;
|
|
using Robust.Shared.Random;
|
|
using Content.Shared.Eye.Blinding.Systems;
|
|
using Content.Shared.Standing;
|
|
|
|
|
|
namespace Content.Server.Flash
|
|
{
|
|
internal sealed class FlashSystem : SharedFlashSystem
|
|
{
|
|
[Dependency] private readonly AppearanceSystem _appearance = default!;
|
|
[Dependency] private readonly AudioSystem _audio = default!;
|
|
[Dependency] private readonly SharedChargesSystem _charges = default!;
|
|
[Dependency] private readonly EntityLookupSystem _entityLookup = default!;
|
|
[Dependency] private readonly IGameTiming _timing = default!;
|
|
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
|
[Dependency] private readonly SharedInteractionSystem _interaction = default!;
|
|
[Dependency] private readonly InventorySystem _inventory = default!;
|
|
[Dependency] private readonly PopupSystem _popup = default!;
|
|
[Dependency] private readonly StunSystem _stun = default!;
|
|
[Dependency] private readonly TagSystem _tag = default!;
|
|
[Dependency] private readonly IRobustRandom _random = default!;
|
|
[Dependency] private readonly BlindableSystem _blindingSystem = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<FlashComponent, MeleeHitEvent>(OnFlashMeleeHit);
|
|
// ran before toggling light for extra-bright lantern
|
|
SubscribeLocalEvent<FlashComponent, UseInHandEvent>(OnFlashUseInHand, before: new []{ typeof(HandheldLightSystem) });
|
|
SubscribeLocalEvent<FlashComponent, ThrowDoHitEvent>(OnFlashThrowHitEvent);
|
|
SubscribeLocalEvent<InventoryComponent, FlashAttemptEvent>(OnInventoryFlashAttempt);
|
|
SubscribeLocalEvent<FlashImmunityComponent, FlashAttemptEvent>(OnFlashImmunityFlashAttempt);
|
|
SubscribeLocalEvent<PermanentBlindnessComponent, FlashAttemptEvent>(OnPermanentBlindnessFlashAttempt);
|
|
SubscribeLocalEvent<TemporaryBlindnessComponent, FlashAttemptEvent>(OnTemporaryBlindnessFlashAttempt);
|
|
}
|
|
|
|
private void OnFlashMeleeHit(EntityUid uid, FlashComponent comp, MeleeHitEvent args)
|
|
{
|
|
if (!args.IsHit ||
|
|
!args.HitEntities.Any() ||
|
|
!UseFlash(uid, comp))
|
|
return;
|
|
|
|
args.Handled = true;
|
|
foreach (var e in args.HitEntities)
|
|
{
|
|
Flash(e, args.User, uid, comp.FlashDuration, comp.SlowTo, melee: true, stunDuration: comp.MeleeStunDuration);
|
|
}
|
|
}
|
|
|
|
private void OnFlashUseInHand(EntityUid uid, FlashComponent comp, UseInHandEvent args)
|
|
{
|
|
if (args.Handled || !UseFlash(uid, comp))
|
|
return;
|
|
|
|
args.Handled = true;
|
|
FlashArea(uid, args.User, comp.Range, comp.AoeFlashDuration, comp.SlowTo, true, comp.Probability);
|
|
}
|
|
|
|
private void OnFlashThrowHitEvent(EntityUid uid, FlashComponent comp, ThrowDoHitEvent args)
|
|
{
|
|
if (!UseFlash(uid, comp))
|
|
return;
|
|
|
|
FlashArea(uid, args.User, comp.Range, comp.AoeFlashDuration, comp.SlowTo, false, comp.Probability);
|
|
}
|
|
|
|
private bool UseFlash(EntityUid uid, FlashComponent comp)
|
|
{
|
|
if (comp.Flashing)
|
|
return false;
|
|
|
|
TryComp<LimitedChargesComponent>(uid, out var charges);
|
|
if (_charges.IsEmpty(uid, charges))
|
|
return false;
|
|
|
|
_charges.UseCharge(uid, charges);
|
|
_audio.PlayPvs(comp.Sound, uid);
|
|
comp.Flashing = true;
|
|
_appearance.SetData(uid, FlashVisuals.Flashing, true);
|
|
|
|
if (_charges.IsEmpty(uid, charges))
|
|
{
|
|
_appearance.SetData(uid, FlashVisuals.Burnt, true);
|
|
_tag.AddTag(uid, "Trash");
|
|
_popup.PopupEntity(Loc.GetString("flash-component-becomes-empty"), uid);
|
|
}
|
|
|
|
uid.SpawnTimer(400, () =>
|
|
{
|
|
_appearance.SetData(uid, FlashVisuals.Flashing, false);
|
|
comp.Flashing = false;
|
|
});
|
|
|
|
return true;
|
|
}
|
|
|
|
public void Flash(EntityUid target,
|
|
EntityUid? user,
|
|
EntityUid? used,
|
|
float flashDuration,
|
|
float slowTo,
|
|
bool displayPopup = true,
|
|
FlashableComponent? flashable = null,
|
|
bool melee = false,
|
|
TimeSpan? stunDuration = null)
|
|
{
|
|
if (!Resolve(target, ref flashable, false))
|
|
return;
|
|
|
|
// WWDP-Start
|
|
if (TryComp<FlashModifierComponent>(target, out var flashModifier))
|
|
{
|
|
flashDuration *= flashModifier.Modifier;
|
|
}
|
|
// WWDP-End
|
|
|
|
var attempt = new FlashAttemptEvent(target, user, used);
|
|
RaiseLocalEvent(target, attempt, true);
|
|
|
|
if (attempt.Cancelled)
|
|
return;
|
|
|
|
if (melee)
|
|
{
|
|
var ev = new AfterFlashedEvent(target, user, used);
|
|
if (user != null)
|
|
RaiseLocalEvent(user.Value, ref ev);
|
|
if (used != null)
|
|
RaiseLocalEvent(used.Value, ref ev);
|
|
}
|
|
|
|
flashDuration *= flashable.DurationMultiplier;
|
|
|
|
flashable.LastFlash = _timing.CurTime;
|
|
flashable.Duration = flashDuration / 1000f; // TODO: Make this sane...
|
|
Dirty(target, flashable);
|
|
|
|
if (HasComp<HearingComponent>(target))
|
|
{
|
|
var deafen = new HearingChangedEvent(target, false, false, flashDuration / 1000f, "deaf-chat-message-flashbanged");
|
|
RaiseLocalEvent(target, deafen);
|
|
}
|
|
|
|
if (TryComp<BlindableComponent>(target, out var blindable)
|
|
&& !blindable.IsBlind
|
|
&& _random.Prob(flashable.EyeDamageChance))
|
|
_blindingSystem.AdjustEyeDamage((target, blindable), flashable.EyeDamage);
|
|
|
|
if (stunDuration != null)
|
|
{
|
|
_stun.TryParalyze(target, stunDuration.Value, true);
|
|
}
|
|
else
|
|
{
|
|
_stun.TrySlowdown(target, TimeSpan.FromSeconds(flashDuration/1000f), true,
|
|
slowTo, slowTo);
|
|
}
|
|
|
|
if (displayPopup && user != null && target != user && Exists(user.Value))
|
|
{
|
|
_popup.PopupEntity(Loc.GetString("flash-component-user-blinds-you",
|
|
("user", Identity.Entity(user.Value, EntityManager))), target, target);
|
|
}
|
|
}
|
|
|
|
// WD EDIT START
|
|
private void FlashStun(EntityUid target, float stunDuration, float knockdownDuration, float distance, float range)
|
|
{
|
|
if (stunDuration <= 0 && knockdownDuration <= 0)
|
|
return;
|
|
|
|
if (TryComp<FlashSoundSuppressionComponent>(target, out var suppression))
|
|
range = MathF.Min(range, suppression.MaxRange);
|
|
|
|
var ev = new FlashbangedEvent(range);
|
|
RaiseLocalEvent(target, ev);
|
|
|
|
range = MathF.Min(range, ev.MaxRange);
|
|
if (range <= 0f)
|
|
return;
|
|
|
|
if (distance < 0f)
|
|
distance = 0f;
|
|
|
|
if (distance > range)
|
|
return;
|
|
|
|
var knockdownTime = float.Lerp(knockdownDuration, 0f, distance / range);
|
|
if (knockdownTime > 0f)
|
|
_stun.TryKnockdown(target, TimeSpan.FromSeconds(knockdownTime), true, DropHeldItemsBehavior.DropIfStanding);
|
|
|
|
var stunTime = float.Lerp(stunDuration, 0f, distance / range);
|
|
if (stunTime > 0f)
|
|
_stun.TryStun(target, TimeSpan.FromSeconds(stunTime), true);
|
|
}
|
|
// WD EDIT END
|
|
|
|
public void FlashArea(Entity<FlashComponent?> source, EntityUid? user, float range, float duration, float slowTo = 0.8f, bool displayPopup = false, float probability = 1f, SoundSpecifier? sound = null, float stunTime = 0f, float knockdownTime = 0f) // WD EDIT
|
|
{
|
|
var transform = Transform(source);
|
|
var mapPosition = _transform.GetMapCoordinates(transform);
|
|
var flashableQuery = GetEntityQuery<FlashableComponent>();
|
|
|
|
foreach (var entity in _entityLookup.GetEntitiesInRange(transform.Coordinates, range))
|
|
{
|
|
if (!_random.Prob(probability))
|
|
continue;
|
|
|
|
if (!flashableQuery.TryGetComponent(entity, out var flashable))
|
|
continue;
|
|
|
|
// Check for unobstructed entities while ignoring the mobs with flashable components.
|
|
if (!_interaction.InRangeUnobstructed(entity, mapPosition, range, flashable.CollisionGroup, predicate: (e) => flashableQuery.HasComponent(e) || e == source.Owner))
|
|
continue;
|
|
|
|
// They shouldn't have flash removed in between right?
|
|
Flash(entity, user, source, duration, slowTo, displayPopup, flashableQuery.GetComponent(entity));
|
|
|
|
// WD EDIT START
|
|
var distance = (mapPosition.Position - _transform.GetMapCoordinates(entity).Position).Length();
|
|
FlashStun(entity, stunTime, knockdownTime, distance, range);
|
|
// WD EDIT END
|
|
}
|
|
|
|
_audio.PlayPvs(sound, source, AudioParams.Default.WithVolume(1f).WithMaxDistance(3f));
|
|
}
|
|
|
|
private void OnInventoryFlashAttempt(EntityUid uid, InventoryComponent component, FlashAttemptEvent args)
|
|
{
|
|
foreach (var slot in new[] { "head", "eyes", "mask" })
|
|
{
|
|
if (args.Cancelled)
|
|
break;
|
|
if (_inventory.TryGetSlotEntity(uid, slot, out var item, component))
|
|
RaiseLocalEvent(item.Value, args, true);
|
|
}
|
|
}
|
|
|
|
private void OnFlashImmunityFlashAttempt(EntityUid uid, FlashImmunityComponent component, FlashAttemptEvent args)
|
|
{
|
|
if(component.Enabled)
|
|
args.Cancel();
|
|
}
|
|
|
|
private void OnPermanentBlindnessFlashAttempt(EntityUid uid, PermanentBlindnessComponent component, FlashAttemptEvent args)
|
|
{
|
|
args.Cancel();
|
|
}
|
|
|
|
private void OnTemporaryBlindnessFlashAttempt(EntityUid uid, TemporaryBlindnessComponent component, FlashAttemptEvent args)
|
|
{
|
|
args.Cancel();
|
|
}
|
|
}
|
|
|
|
public sealed class FlashAttemptEvent : CancellableEntityEventArgs
|
|
{
|
|
public readonly EntityUid Target;
|
|
public readonly EntityUid? User;
|
|
public readonly EntityUid? Used;
|
|
|
|
public FlashAttemptEvent(EntityUid target, EntityUid? user, EntityUid? used)
|
|
{
|
|
Target = target;
|
|
User = user;
|
|
Used = used;
|
|
}
|
|
}
|
|
}
|