Magic and gamerule tweaks (#363)
* - tweak: Wiz hardsuit tweaks. * - tweak: Gamemode tweaks. * - add: Mindswap spell. * - add: Transfer wizard component on mindswap. * - add: Wizard is blight immune.
This commit is contained in:
@@ -13,14 +13,18 @@ using Content.Server.Emp;
|
||||
using Content.Server.EUI;
|
||||
using Content.Server.Lightning;
|
||||
using Content.Server.Magic;
|
||||
using Content.Server.Mind;
|
||||
using Content.Server.Singularity.EntitySystems;
|
||||
using Content.Server.Standing;
|
||||
using Content.Server.Weapons.Ranged.Systems;
|
||||
using Content.Shared._White.BetrayalDagger;
|
||||
using Content.Shared._White.Cult.Components;
|
||||
using Content.Shared._White.Events;
|
||||
using Content.Shared._White.Wizard;
|
||||
using Content.Shared._White.Wizard.Magic;
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Borer;
|
||||
using Content.Shared.Changeling;
|
||||
using Content.Shared.Cluwne;
|
||||
using Content.Shared.Coordinates.Helpers;
|
||||
using Content.Shared.Hands.Components;
|
||||
@@ -35,6 +39,7 @@ using Content.Shared.Maps;
|
||||
using Content.Shared.Mobs.Components;
|
||||
using Content.Shared.Physics;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Revolutionary.Components;
|
||||
using Content.Shared.StatusEffect;
|
||||
using Content.Shared.Throwing;
|
||||
using Robust.Shared.Audio.Systems;
|
||||
@@ -71,6 +76,8 @@ public sealed class WizardSpellsSystem : EntitySystem
|
||||
[Dependency] private readonly StandingStateSystem _standing = default!;
|
||||
[Dependency] private readonly TelefragSystem _telefrag = default!;
|
||||
[Dependency] private readonly EuiManager _euiManager = default!;
|
||||
[Dependency] private readonly MindSystem _mindSystem = default!;
|
||||
[Dependency] private readonly ActionContainerSystem _actionContainer = default!;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -78,6 +85,7 @@ public sealed class WizardSpellsSystem : EntitySystem
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<MindswapSpellEvent>(OnMindswapSpell);
|
||||
SubscribeLocalEvent<TeleportSpellEvent>(OnTeleportSpell);
|
||||
SubscribeLocalEvent<InstantRecallSpellEvent>(OnInstantRecallSpell);
|
||||
SubscribeLocalEvent<MimeTouchSpellEvent>(OnMimeTouchSpell);
|
||||
@@ -95,6 +103,73 @@ public sealed class WizardSpellsSystem : EntitySystem
|
||||
SubscribeLocalEvent<MagicComponent, BeforeCastSpellEvent>(OnBeforeCastSpell);
|
||||
}
|
||||
|
||||
#region Mindswap
|
||||
|
||||
private void OnMindswapSpell(MindswapSpellEvent msg)
|
||||
{
|
||||
if (!CanCast(msg))
|
||||
return;
|
||||
|
||||
var target = msg.Target;
|
||||
var uid = msg.Performer;
|
||||
|
||||
if (HasComp<ChangelingComponent>(target) || HasComp<RevolutionaryComponent>(target) ||
|
||||
HasComp<CultistComponent>(target))
|
||||
{
|
||||
_popupSystem.PopupEntity("Не работает на культистов, генокрадов и революционеров.", uid, uid,
|
||||
PopupType.MediumCaution);
|
||||
return;
|
||||
}
|
||||
|
||||
if (TryComp(target, out InfestedBorerComponent? borer) && borer.ControllingBrain)
|
||||
{
|
||||
_popupSystem.PopupEntity("Им уже кто-то управляет.", uid, uid, PopupType.MediumCaution);
|
||||
return;
|
||||
}
|
||||
|
||||
var userHasMind = _mindSystem.TryGetMind(uid, out var mindId, out var mind);
|
||||
var targetHasMind = _mindSystem.TryGetMind(target, out var targetMindId, out var targetMind);
|
||||
|
||||
if (!userHasMind)
|
||||
return;
|
||||
|
||||
_mindSystem.TransferTo(mindId, target, mind: mind);
|
||||
|
||||
if (targetHasMind)
|
||||
{
|
||||
_mindSystem.TransferTo(targetMindId, uid, mind: targetMind);
|
||||
_popupSystem.PopupEntity(Loc.GetString("Ваш разум подменили!"), uid, uid, PopupType.LargeCaution);
|
||||
}
|
||||
|
||||
TransferAllMagicActions(uid, target);
|
||||
|
||||
_standing.TryLieDown(uid);
|
||||
_standing.TryLieDown(target);
|
||||
|
||||
msg.Handled = true;
|
||||
Speak(msg);
|
||||
|
||||
var hasWiz = HasComp<WizardComponent>(uid);
|
||||
var targetHasWiz = HasComp<WizardComponent>(target);
|
||||
|
||||
if (hasWiz == targetHasWiz)
|
||||
return;
|
||||
|
||||
if (hasWiz)
|
||||
{
|
||||
RemComp<WizardComponent>(uid);
|
||||
EnsureComp<WizardComponent>(target);
|
||||
}
|
||||
|
||||
if (targetHasWiz)
|
||||
{
|
||||
RemComp<WizardComponent>(target);
|
||||
EnsureComp<WizardComponent>(uid);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Teleport
|
||||
|
||||
private void OnTeleportSpell(TeleportSpellEvent msg)
|
||||
@@ -797,27 +872,48 @@ public sealed class WizardSpellsSystem : EntitySystem
|
||||
private void OnBeforeCastSpell(Entity<MagicComponent> ent, ref BeforeCastSpellEvent args)
|
||||
{
|
||||
var comp = ent.Comp;
|
||||
|
||||
if (!comp.RequiresClothes)
|
||||
return;
|
||||
|
||||
var hasReqs = false;
|
||||
|
||||
if (comp.RequiresClothes)
|
||||
var enumerator = _inventory.GetSlotEnumerator(args.Performer, SlotFlags.OUTERCLOTHING | SlotFlags.HEAD);
|
||||
while (enumerator.MoveNext(out var containerSlot))
|
||||
{
|
||||
var enumerator = _inventory.GetSlotEnumerator(args.Performer, SlotFlags.OUTERCLOTHING | SlotFlags.HEAD);
|
||||
while (enumerator.MoveNext(out var containerSlot))
|
||||
{
|
||||
if (containerSlot.ContainedEntity is { } item)
|
||||
hasReqs = HasComp<WizardClothesComponent>(item);
|
||||
else
|
||||
hasReqs = false;
|
||||
if (containerSlot.ContainedEntity is { } item)
|
||||
hasReqs = HasComp<WizardClothesComponent>(item);
|
||||
else
|
||||
hasReqs = false;
|
||||
|
||||
if (!hasReqs)
|
||||
break;
|
||||
}
|
||||
if (!hasReqs)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!hasReqs)
|
||||
if (hasReqs)
|
||||
return;
|
||||
|
||||
args.Cancelled = true;
|
||||
_popupSystem.PopupEntity(Loc.GetString("magic-component-missing-req"), args.Performer, args.Performer);
|
||||
}
|
||||
|
||||
private void TransferAllMagicActions(EntityUid uid1, EntityUid uid2)
|
||||
{
|
||||
if (!TryComp(uid1, out ActionsContainerComponent? container1) ||
|
||||
!TryComp(uid2, out ActionsContainerComponent? container2))
|
||||
return;
|
||||
|
||||
var actions1 = container1.Container.ContainedEntities.Where(HasComp<MagicComponent>).ToList();
|
||||
var actions2 = container2.Container.ContainedEntities.Where(HasComp<MagicComponent>).ToList();
|
||||
|
||||
foreach (var act in actions1)
|
||||
{
|
||||
args.Cancelled = true;
|
||||
_popupSystem.PopupEntity(Loc.GetString("magic-component-missing-req"), args.Performer, args.Performer);
|
||||
_actionContainer.TransferActionWithNewAttached(act, uid2, uid2, container: container2);
|
||||
}
|
||||
|
||||
foreach (var act in actions2)
|
||||
{
|
||||
_actionContainer.TransferActionWithNewAttached(act, uid1, uid1, container: container1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ public sealed partial class WizardRuleComponent : Component
|
||||
[DataField]
|
||||
public ProtoId<NpcFactionPrototype> Faction = "Wizard";
|
||||
|
||||
public RoundEndBehavior RoundEndBehavior = RoundEndBehavior.ShuttleCall;
|
||||
public RoundEndBehavior RoundEndBehavior = RoundEndBehavior.InstantEnd;
|
||||
|
||||
[DataField]
|
||||
public string RoundEndTextSender = "comms-console-announcement-title-centcom";
|
||||
|
||||
@@ -23,6 +23,7 @@ using Robust.Shared.Prototypes;
|
||||
using System.Linq;
|
||||
using Content.Server.Objectives;
|
||||
using Content.Server.Station.Components;
|
||||
using Content.Server.StationEvents.Components;
|
||||
using Content.Shared.Mind;
|
||||
using Content.Shared.NPC.Components;
|
||||
using Content.Shared.Objectives.Components;
|
||||
@@ -62,7 +63,6 @@ public sealed class WizardRuleSystem : GameRuleSystem<WizardRuleComponent>
|
||||
SubscribeLocalEvent<RoundStartAttemptEvent>(OnStartAttempt);
|
||||
SubscribeLocalEvent<RulePlayerSpawningEvent>(OnPlayersSpawning);
|
||||
SubscribeLocalEvent<GameRunLevelChangedEvent>(OnRunLevelChanged);
|
||||
SubscribeLocalEvent<WizardComponent, ComponentRemove>(OnComponentRemove);
|
||||
SubscribeLocalEvent<WizardComponent, MobStateChangedEvent>(OnMobStateChanged);
|
||||
SubscribeLocalEvent<WizardComponent, GhostRoleSpawnerUsedEvent>(OnPlayersGhostSpawning);
|
||||
SubscribeLocalEvent<WizardComponent, MindAddedMessage>(OnMindAdded);
|
||||
@@ -123,11 +123,6 @@ public sealed class WizardRuleSystem : GameRuleSystem<WizardRuleComponent>
|
||||
SpawnWizardGhostRole(uid, component);
|
||||
}
|
||||
|
||||
private void OnComponentRemove(EntityUid uid, WizardComponent component, ComponentRemove args)
|
||||
{
|
||||
CheckAnnouncement();
|
||||
}
|
||||
|
||||
private void OnMobStateChanged(EntityUid uid, WizardComponent component, MobStateChangedEvent ev)
|
||||
{
|
||||
if (ev.NewMobState == MobState.Dead)
|
||||
@@ -249,6 +244,10 @@ public sealed class WizardRuleSystem : GameRuleSystem<WizardRuleComponent>
|
||||
|
||||
private void CheckAnnouncement()
|
||||
{
|
||||
// Check for all at once gamemode
|
||||
if (GameTicker.GetActiveGameRules().Where(HasComp<RampingStationEventSchedulerComponent>).Any())
|
||||
return;
|
||||
|
||||
var query = QueryActiveRules();
|
||||
while (query.MoveNext(out _, out _, out var wizard, out _))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user