Skip to content

Commit

Permalink
the return of player character spawners (feat. mindshield bullshit) (#…
Browse files Browse the repository at this point in the history
…2072)

* aaaaaaaaaaa

* guh

* epic fail

* fuck it we ball
  • Loading branch information
MilonPL authored Nov 6, 2024
1 parent c10de70 commit 1e0c4f3
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace Content.Server.Ghost.Roles.Components
using Content.Shared.Roles;
using Robust.Shared.Prototypes;

namespace Content.Server.Ghost.Roles.Components
{
/// <summary>
/// Allows a ghost to take this role, spawning their selected character.
Expand All @@ -7,16 +10,22 @@
[Access(typeof(GhostRoleSystem))]
public sealed partial class GhostRoleCharacterSpawnerComponent : Component
{
[ViewVariables(VVAccess.ReadWrite)] [DataField("deleteOnSpawn")]
[DataField]
public bool DeleteOnSpawn = true;

[ViewVariables(VVAccess.ReadWrite)] [DataField("availableTakeovers")]
[DataField]
public int AvailableTakeovers = 1;

[ViewVariables]
public int CurrentTakeovers = 0;

[ViewVariables(VVAccess.ReadWrite)] [DataField("outfitPrototype")]
public string OutfitPrototype = "PassengerGear";
[DataField]
public ProtoId<StartingGearPrototype> OutfitPrototype = "PassengerGear";

/// <summary>
/// Components to give on spawn.
/// </summary>
[DataField]
public ComponentRegistry AddedComponents = new();
}
}
16 changes: 7 additions & 9 deletions Content.Server/DeltaV/Ghost/Roles/GhostRoleSystem.Character.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
using Content.Server.Station.Systems;
using Content.Shared.Mind.Components;
using Content.Shared.Preferences;
using Content.Shared.Roles;
using Robust.Shared.Prototypes;

namespace Content.Server.Ghost.Roles
{
Expand All @@ -15,9 +13,12 @@ public sealed partial class GhostRoleSystem
[Dependency] private readonly IServerPreferencesManager _prefs = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;

private void OnSpawnerTakeCharacter( EntityUid uid, GhostRoleCharacterSpawnerComponent component,
private void OnSpawnerTakeCharacter(Entity<GhostRoleCharacterSpawnerComponent> ent,
ref TakeGhostRoleEvent args)
{
var uid = ent.Owner;
var component = ent.Comp;

if (!TryComp(uid, out GhostRoleComponent? ghostRole) ||
ghostRole.Taken)
{
Expand All @@ -31,19 +32,16 @@ private void OnSpawnerTakeCharacter( EntityUid uid, GhostRoleCharacterSpawnerCom
.SpawnPlayerMob(Transform(uid).Coordinates, null, character, null);
_transform.AttachToGridOrMap(mob);

string? outfit = null;
if (_prototype.TryIndex<StartingGearPrototype>(component.OutfitPrototype, out var outfitProto))
outfit = outfitProto.ID;

var spawnedEvent = new GhostRoleSpawnerUsedEvent(uid, mob);
RaiseLocalEvent(mob, spawnedEvent);

EnsureComp<MindContainerComponent>(mob);

GhostRoleInternalCreateMindAndTransfer(args.Player, uid, mob, ghostRole);

if (outfit != null)
SetOutfitCommand.SetOutfit(mob, outfit, _entityManager);
SetOutfitCommand.SetOutfit(mob, component.OutfitPrototype, _entityManager);

EntityManager.AddComponents(mob, component.AddedComponents);

if (++component.CurrentTakeovers < component.AvailableTakeovers)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
- type: entity
categories: [ HideSpawnMenu, Spawner ]
categories: [ Spawner ]
parent: MarkerBase
id: SpawnPointPlayerCharacter
name: ghost role spawn point
suffix: player character, DO NOT MAP
suffix: player character
components:
- type: GhostRole
name: Roleplay Ghost Role
description: Placeholder
rules: Placeholder
description: This is a custom event ghost role.
rules: ghost-role-component-default-rules
- type: GhostRoleCharacterSpawner
- type: Sprite
sprite: Markers/jobs.rsi
Expand All @@ -17,6 +17,28 @@
- sprite: Mobs/Species/Human/parts.rsi
state: full

- type: entity
parent: SpawnPointPlayerCharacter
id: SpawnPointPlayerCharacterMindShield
name: ghost role spawn point
suffix: mindshielded, player character
components:
- type: GhostRoleCharacterSpawner
addedComponents:
- type: MindShield

- type: entity
parent: SpawnPointPlayerCharacter
id: SpawnPointPlayerCharacterTargetImmune
name: ghost role spawn point
suffix: mindshielded, KillObjectiveImmune, player character
components:
- type: GhostRoleCharacterSpawner
addedComponents:
- type: MindShield
- type: AntagImmune
- type: TargetObjectiveImmune

- type: entity # Part of ListeningPost
categories: [ HideSpawnMenu, Spawner ]
parent: BaseAntagSpawner
Expand Down

0 comments on commit 1e0c4f3

Please sign in to comment.