Files
wwdpublic/Content.Shared/Revolutionary/RevolutionaryConverterSystem.cs
Timfa 63773c7218 Revolutionary Manifesto (#1878)
<!--
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)
2025-03-08 14:51:36 +03:00

111 lines
4.0 KiB
C#

using Content.Shared.Chat;
using Content.Shared.DoAfter;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Mobs.Components;
using Content.Shared.Revolutionary.Components;
namespace Content.Shared.Revolutionary;
public sealed class RevolutionaryConverterSystem : EntitySystem
{
private const string RevConvertSpeechBaseKey = "revolutionary-converter-speech-";
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
[Dependency] private readonly SharedChatSystem _chat = default!;
private List<string> _speechLocalizationKeys = new();
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<RevolutionaryConverterComponent, RevolutionaryConverterDoAfterEvent>(OnConvertDoAfter);
SubscribeLocalEvent<RevolutionaryConverterComponent, UseInHandEvent>(OnUseInHand);
SubscribeLocalEvent<RevolutionaryConverterComponent, AfterInteractEvent>(OnConverterAfterInteract);
var i = 1;
while (Loc.HasString($"{RevConvertSpeechBaseKey}{i}"))
{
_speechLocalizationKeys.Add($"{RevConvertSpeechBaseKey}{i}");
i++;
}
}
private void OnUseInHand(Entity<RevolutionaryConverterComponent> ent, ref UseInHandEvent args)
{
if(_speechLocalizationKeys == null || _speechLocalizationKeys.Count == 0)
return;
var message = _speechLocalizationKeys[System.Random.Shared.Next(_speechLocalizationKeys.Count)];
_chat.TrySendInGameICMessage(args.User, Loc.GetString(message), InGameICChatType.Speak, hideChat: false, hideLog: false);
args.Handled = true;
}
public void OnConvertDoAfter(Entity<RevolutionaryConverterComponent> entity, ref RevolutionaryConverterDoAfterEvent args)
{
if (args.Target == null || args.Cancelled)
return;
var ev = new AfterConvertedEvent(args.Target!.Value, args.User, args.Used);
RaiseLocalEvent(args.User, ref ev);
if (args.Used != null)
RaiseLocalEvent(args.Used.Value, ref ev);
}
public void OnConverterAfterInteract(Entity<RevolutionaryConverterComponent> entity, ref AfterInteractEvent args)
{
if (args.Handled || !args.CanReach)
return;
if (args.Target is not { Valid: true } target || !HasComp<MobStateComponent>(target) || !HasComp<HeadRevolutionaryComponent>(args.User))
return;
ConvertDoAfter(entity, target, args.User);
args.Handled = true;
}
private void ConvertDoAfter(Entity<RevolutionaryConverterComponent> converter, EntityUid target, EntityUid user)
{
if (user == target)
return;
if(_speechLocalizationKeys != null && _speechLocalizationKeys.Count > 0)
{
var message = _speechLocalizationKeys[System.Random.Shared.Next(_speechLocalizationKeys.Count)];
_chat.TrySendInGameICMessage(user, Loc.GetString(message), InGameICChatType.Speak, hideChat: false, hideLog: false);
}
_doAfter.TryStartDoAfter(new DoAfterArgs(EntityManager, user, converter.Comp.ConversionDuration, new RevolutionaryConverterDoAfterEvent(), converter.Owner, target: target, used: converter.Owner)
{
BreakOnMove = false,
BreakOnWeightlessMove = false,
BreakOnDamage = true,
NeedHand = true,
BreakOnHandChange = false,
});
}
/// <summary>
/// Called after a converter is used via melee on another person to check for rev conversion.
/// Raised on the user of the converter, the target hit by the converter, and the converter used.
/// </summary>
[ByRefEvent]
public readonly struct AfterConvertedEvent
{
public readonly EntityUid Target;
public readonly EntityUid? User;
public readonly EntityUid? Used;
public AfterConvertedEvent(EntityUid target, EntityUid? user, EntityUid? used)
{
Target = target;
User = user;
Used = used;
}
}
}