Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metempsychosis Returns #685

Merged
merged 56 commits into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
af038b0
Metempsychosis Returns
VMSolidus Jan 17, 2024
85b0e47
Last updates
VMSolidus Jan 17, 2024
a982402
Fixin the linter
VMSolidus Jan 17, 2024
8f10d6b
Update lathe.yml
VMSolidus Jan 17, 2024
a9dbde1
Update CloningSystem.cs
VMSolidus Jan 17, 2024
ec79134
Merge branch 'master' into Metempsychosis
VMSolidus Jan 22, 2024
556e62f
Merge branch 'Metempsychosis' of https://github.com/evilexecutive/Del…
VMSolidus Jan 22, 2024
b88d3c3
Fixing the random name bug
VMSolidus Jan 22, 2024
47586c3
Fugitive, rough but functional
VMSolidus Jan 22, 2024
13124db
Update fugitive.yml
VMSolidus Jan 23, 2024
5af8fbd
Update humanoid.yml
VMSolidus Jan 23, 2024
51d3355
Checking if its the floortile
VMSolidus Jan 23, 2024
bc98f0f
Guh
VMSolidus Jan 23, 2024
82375ac
Update EntityTest.cs
VMSolidus Jan 23, 2024
924eff4
Revert "Update EntityTest.cs"
VMSolidus Jan 23, 2024
667b8c5
Revert "Guh"
VMSolidus Jan 23, 2024
8630ce0
Revert "Checking if its the floortile"
VMSolidus Jan 23, 2024
cb27625
Revert "Update humanoid.yml"
VMSolidus Jan 23, 2024
cf1293e
Revert "Update fugitive.yml"
VMSolidus Jan 23, 2024
a605aa4
Revert "Fugitive, rough but functional"
VMSolidus Jan 23, 2024
dfd76b0
Merge branch 'master' into Metempsychosis
VMSolidus Jan 23, 2024
49e704e
Update Content.Server/Medical/Components/MedicalScannerComponent.cs
VMSolidus Jan 24, 2024
6eb6fbc
Update Content.Server/Nyanotrasen/Cloning/MetempsychosisKarmaComponen…
VMSolidus Jan 24, 2024
8dd1b91
Update Content.Server/Nyanotrasen/Cloning/MetempsychoticMachineCompon…
VMSolidus Jan 24, 2024
62bf453
Update Content.Server/Nyanotrasen/Cloning/MetempsychoticMachineSystem.cs
VMSolidus Jan 24, 2024
6c99f2e
Update Content.Server/Nyanotrasen/Cloning/MetempsychoticMachineSystem.cs
VMSolidus Jan 24, 2024
692eeda
Update Content.Server/Nyanotrasen/Cloning/MetempsychoticMachineSystem.cs
VMSolidus Jan 24, 2024
b9c61ab
Update Resources/Prototypes/Nyanotrasen/Entities/Structures/Machines/…
VMSolidus Jan 24, 2024
4974308
Update Resources/Prototypes/Nyanotrasen/Research/biochemical.yml.yml
VMSolidus Jan 24, 2024
f98a4f8
Update Resources/Textures/Nyanotrasen/Structures/Machines/metempsycho…
VMSolidus Jan 24, 2024
7d9b75e
Update CloningSystem.cs
VMSolidus Jan 24, 2024
26a5217
Update CloningSystem.cs
VMSolidus Jan 24, 2024
b0e21ca
Merge branch 'master' into Metempsychosis
VMSolidus Jan 28, 2024
dae42fc
Update Content.Server/Nyanotrasen/Cloning/MetempsychoticMachineSystem.cs
VMSolidus Jan 28, 2024
2d75497
Update MetempsychoticMachineSystem.cs
VMSolidus Jan 28, 2024
1868e8a
Merge branch 'Metempsychosis' of https://github.com/evilexecutive/Del…
VMSolidus Jan 28, 2024
5cf580e
Merge branch 'master' into Metempsychosis
VMSolidus Jan 28, 2024
a793dbe
Cleaning up some of the Metem code
VMSolidus Jan 28, 2024
1d36641
Update CloningConsoleSystem.cs
VMSolidus Jan 28, 2024
a5a2df7
Reordering usings for less merge conflicts
VMSolidus Jan 28, 2024
384fb60
Update HumanoidAppearanceComponent.cs
VMSolidus Jan 28, 2024
ed2abac
Update CloningSystem.cs
VMSolidus Jan 28, 2024
cb5ebb1
Merge branch 'master' into Metempsychosis
VMSolidus Jan 28, 2024
c5fd613
Apply suggestions from code review
VMSolidus Feb 2, 2024
688ab0b
Update CloningConsoleSystem.cs
VMSolidus Feb 2, 2024
32b7245
Update CloningConsoleSystem.cs
VMSolidus Feb 2, 2024
2596e70
Update CloningSystem.cs
VMSolidus Feb 2, 2024
0b4aa61
Update CloningConsoleSystem.cs
VMSolidus Feb 2, 2024
177bd5c
Apply suggestions from code review
VMSolidus Feb 8, 2024
0a67fae
Requested changes but need assistance with test fail
VMSolidus Feb 9, 2024
63ad078
Merge branch 'master' into Metempsychosis
VMSolidus Feb 9, 2024
27b8ac8
biochem is gone apparently
VMSolidus Feb 9, 2024
eaa031e
Update experimental.yml
VMSolidus Feb 9, 2024
f8a306b
Update MetempsychosisTest.cs
VMSolidus Feb 9, 2024
448e4dc
Update CloningSystem.cs
VMSolidus Feb 9, 2024
e73f454
Merge branch 'master' into Metempsychosis
VMSolidus Feb 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Content.Server/Cloning/CloningConsoleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public sealed class CloningConsoleSystem : EntitySystem
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
[Dependency] private readonly PowerReceiverSystem _powerReceiverSystem = default!;
[Dependency] private readonly SharedMindSystem _mindSystem = default!;

VMSolidus marked this conversation as resolved.
Show resolved Hide resolved
public override void Initialize()
{
base.Initialize();
Expand Down Expand Up @@ -169,8 +169,8 @@ public void TryClone(EntityUid uid, EntityUid cloningPodUid, EntityUid scannerUi

if (mind.UserId.HasValue == false || mind.Session == null)
return;

if (_cloningSystem.TryCloning(cloningPodUid, body.Value, (mindId, mind), cloningPod, scannerComp.CloningFailChanceMultiplier))
// Nyano: Adds scannerComp.MetemKarmaBonus
if (_cloningSystem.TryCloning(cloningPodUid, body.Value, (mindId, mind), cloningPod, scannerComp.CloningFailChanceMultiplier, scannerComp.MetemKarmaBonus))
VMSolidus marked this conversation as resolved.
Show resolved Hide resolved
_adminLogger.Add(LogType.Action, LogImpact.Medium, $"{ToPrettyString(uid)} successfully cloned {ToPrettyString(body.Value)}.");
}

Expand Down
110 changes: 102 additions & 8 deletions Content.Server/Cloning/CloningSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,18 @@
using Robust.Shared.Physics.Components;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Content.Server.Psionics;
using Content.Server.Traits.Assorted; //Nyano - Summary: allows the potential psionic ability to be written to the character.
using Content.Server.Psionics; //DeltaV needed for Psionic Systems
using Content.Shared.Speech; //DeltaV Start Metem Usings
using Content.Shared.Tag;
using Content.Shared.Preferences;
using Content.Shared.Emoting;
using Content.Server.Speech.Components;
using Content.Server.StationEvents.Components;
using Content.Server.Ghost.Roles.Components;
using Content.Server.Nyanotrasen.Cloning;
using Content.Shared.Humanoid.Prototypes;
using Robust.Shared.GameObjects.Components.Localization; //DeltaV End Metem Usings

namespace Content.Server.Cloning
{
Expand Down Expand Up @@ -62,6 +72,8 @@ public sealed class CloningSystem : EntitySystem
[Dependency] private readonly SharedMindSystem _mindSystem = default!;
[Dependency] private readonly MetaDataSystem _metaSystem = default!;
[Dependency] private readonly SharedJobSystem _jobs = default!;
[Dependency] private readonly MetempsychoticMachineSystem _metem = default!; //DeltaV
[Dependency] private readonly TagSystem _tag = default!; //DeltaV

public readonly Dictionary<MindComponent, EntityUid> ClonesWaitingForMind = new();
public const float EasyModeCloningCost = 0.7f;
Expand All @@ -76,7 +88,6 @@ public override void Initialize()
SubscribeLocalEvent<CloningPodComponent, PortDisconnectedEvent>(OnPortDisconnected);
SubscribeLocalEvent<CloningPodComponent, AnchorStateChangedEvent>(OnAnchor);
SubscribeLocalEvent<CloningPodComponent, ExaminedEvent>(OnExamined);
SubscribeLocalEvent<CloningPodComponent, GotEmaggedEvent>(OnEmagged);
}

private void OnComponentInit(EntityUid uid, CloningPodComponent clonePod, ComponentInit args)
Expand Down Expand Up @@ -136,8 +147,8 @@ private void OnExamined(EntityUid uid, CloningPodComponent component, ExaminedEv

args.PushMarkup(Loc.GetString("cloning-pod-biomass", ("number", _material.GetMaterialAmount(uid, component.RequiredMaterial))));
}

public bool TryCloning(EntityUid uid, EntityUid bodyToClone, Entity<MindComponent> mindEnt, CloningPodComponent? clonePod, float failChanceModifier = 1)
// Nyano: Adds float karmaBonus
public bool TryCloning(EntityUid uid, EntityUid bodyToClone, Entity<MindComponent> mindEnt, CloningPodComponent? clonePod, float failChanceModifier = 1, float karmaBonus = 0.25f)
{
if (!Resolve(uid, ref clonePod))
return false;
Expand Down Expand Up @@ -167,6 +178,13 @@ public bool TryCloning(EntityUid uid, EntityUid bodyToClone, Entity<MindComponen
if (!TryComp<HumanoidAppearanceComponent>(bodyToClone, out var humanoid))
return false; // whatever body was to be cloned, was not a humanoid

// Begin Nyano-code: allow paradox anomalies to be cloned.
var pref = humanoid.LastProfileLoaded;
// End Nyano-code.

if (pref == null)
return false;

VMSolidus marked this conversation as resolved.
Show resolved Hide resolved
if (!_prototype.TryIndex(humanoid.Species, out var speciesPrototype))
return false;

Expand Down Expand Up @@ -222,11 +240,11 @@ public bool TryCloning(EntityUid uid, EntityUid bodyToClone, Entity<MindComponen
AddComp<ActiveCloningPodComponent>(uid);
return true;
}
// End Nyano-code.
}
// end of genetic damage checks

var mob = Spawn(speciesPrototype.Prototype, Transform(uid).MapPosition);
_humanoidSystem.CloneAppearance(bodyToClone, mob);
var mob = FetchAndSpawnMob(clonePod, pref, speciesPrototype, humanoid, bodyToClone, karmaBonus); //DeltaV Replaces CloneAppearance with Metem/Clone via FetchAndSpawnMob

///Nyano - Summary: adds the potential psionic trait to the reanimated mob.
EnsureComp<PotentialPsionicComponent>(mob);
Expand All @@ -247,7 +265,7 @@ public bool TryCloning(EntityUid uid, EntityUid bodyToClone, Entity<MindComponen

AddComp<ActiveCloningPodComponent>(uid);

// TODO: Ideally, components like this should be components on the mind entity so this isn't necessary.
// TODO: Ideally, components like this should be on a mind entity so this isn't neccesary.
DebugOk marked this conversation as resolved.
Show resolved Hide resolved
// Add on special job components to the mob.
if (_jobs.MindTryGetJob(mindEnt, out _, out var prototype))
{
Expand Down Expand Up @@ -326,7 +344,6 @@ private void EndFailedCloning(EntityUid uid, CloningPodComponent clonePod)
var transform = Transform(uid);
var indices = _transformSystem.GetGridTilePositionOrDefault((uid, transform));
var tileMix = _atmosphereSystem.GetTileMixture(transform.GridUid, null, indices, true);

if (HasComp<EmaggedComponent>(uid))
{
_audio.PlayPvs(clonePod.ScreamSound, uid);
Expand Down Expand Up @@ -354,6 +371,83 @@ private void EndFailedCloning(EntityUid uid, CloningPodComponent clonePod)
RemCompDeferred<ActiveCloningPodComponent>(uid);
}

/// <summary>
/// Start Nyano Code: Handles fetching the mob and any appearance stuff...
/// </summary>
private EntityUid FetchAndSpawnMob(CloningPodComponent clonePod, HumanoidCharacterProfile pref, SpeciesPrototype speciesPrototype, HumanoidAppearanceComponent humanoid, EntityUid bodyToClone, float karmaBonus)
{
List<Sex> sexes = new();
bool switchingSpecies = false;
bool applyKarma = false;
var toSpawn = speciesPrototype.Prototype;
TryComp<MetempsychosisKarmaComponent>(bodyToClone, out var oldKarma);

if (TryComp<MetempsychoticMachineComponent>(clonePod.Owner, out var metem))
{
toSpawn = _metem.GetSpawnEntity(clonePod.Owner, karmaBonus, speciesPrototype, out var newSpecies, oldKarma?.Score, metem);
applyKarma = true;

if (newSpecies != null)
{
sexes = newSpecies.Sexes;

if (speciesPrototype.ID != newSpecies.ID)
{
switchingSpecies = true;
}
VMSolidus marked this conversation as resolved.
Show resolved Hide resolved

speciesPrototype = newSpecies;
}
}

var mob = Spawn(toSpawn, Transform(clonePod.Owner).MapPosition);
if (TryComp<HumanoidAppearanceComponent>(mob, out var newHumanoid))
{
if (switchingSpecies || HasComp<MetempsychosisKarmaComponent>(bodyToClone))
{
pref = HumanoidCharacterProfile.RandomWithSpecies(newHumanoid.Species);
if (sexes.Contains(humanoid.Sex))
pref = pref.WithSex(humanoid.Sex);

pref = pref.WithGender(humanoid.Gender);
pref = pref.WithAge(humanoid.Age);

}
_humanoidSystem.LoadProfile(mob, pref);
}

if (applyKarma)
{
var karma = EnsureComp<MetempsychosisKarmaComponent>(mob);
karma.Score++;
if (oldKarma != null)
karma.Score += oldKarma.Score;
}

var ev = new CloningEvent(bodyToClone, mob);
RaiseLocalEvent(bodyToClone, ref ev);

if (!ev.NameHandled)
_metaSystem.SetEntityName(mob, MetaData(bodyToClone).EntityName);

var grammar = EnsureComp<GrammarComponent>(mob);
grammar.ProperNoun = true;
grammar.Gender = humanoid.Gender;
Dirty(grammar);

EnsureComp<PotentialPsionicComponent>(mob);
EnsureComp<SpeechComponent>(mob);
EnsureComp<EmotingComponent>(mob);
RemComp<ReplacementAccentComponent>(mob);
RemComp<MonkeyAccentComponent>(mob);
RemComp<SentienceTargetComponent>(mob);
RemComp<GhostTakeoverAvailableComponent>(mob);

_tag.AddTag(mob, "DoorBumpOpener");

return mob;
}
//End Nyano Code
public void Reset(RoundRestartCleanupEvent ev)
{
ClonesWaitingForMind.Clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,14 @@ public sealed partial class MedicalScannerComponent : SharedMedicalScannerCompon

[DataField, ViewVariables(VVAccess.ReadWrite)]
public float CloningFailChanceMultiplier = 1f;

// Nyano, needed for Metem Machine.
public float MetemKarmaBonus = 0.25f;

[DataField("machinePartCloningFailChance", customTypeSerializer: typeof(PrototypeIdSerializer<MachinePartPrototype>))]
public string MachinePartCloningFailChance = "Capacitor";

DebugOk marked this conversation as resolved.
Show resolved Hide resolved
[DataField("partRatingCloningFailChanceMultiplier")]
public float PartRatingFailMultiplier = 0.75f;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace Content.Server.Nyanotrasen.Cloning
{
/// <summary>
/// This tracks how many times you have already been cloned and lowers your chance of getting a humanoid each time.
/// </summary>
[RegisterComponent]
public sealed partial class MetempsychosisKarmaComponent : Component
{
[DataField("score")]
public int Score = 0;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace Content.Server.Nyanotrasen.Cloning
{
[RegisterComponent]
public sealed partial class MetempsychoticMachineComponent : Component
{
/// <summary>
/// Chance you will spawn as a humanoid instead of a non humanoid.
/// </summary>
[DataField("humanoidBaseChance")]
public float HumanoidBaseChance = 0.75f;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using Content.Shared.Humanoid.Prototypes;
using Content.Shared.Random;
using Content.Shared.Random.Helpers;
using Robust.Shared.Random;
using Robust.Shared.Prototypes;

namespace Content.Server.Nyanotrasen.Cloning
{
public sealed class MetempsychoticMachineSystem : EntitySystem
{
[ValidatePrototypeId<WeightedRandomPrototype>]
public const string MetempsychoticHumanoidPool = "MetempsychoticHumanoidPool";

[ValidatePrototypeId<WeightedRandomPrototype>]
public const string MetempsychoticNonHumanoidPool = "MetempsychoticNonhumanoidPool";

[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;

private ISawmill _sawmill = default!;

public string GetSpawnEntity(EntityUid uid, float karmaBonus, SpeciesPrototype oldSpecies, out SpeciesPrototype? species, int? karma = null, MetempsychoticMachineComponent? component = null)
{
if (!Resolve(uid, ref component))
{
Logger.Error("Tried to get a spawn target from someone that was not a metempsychotic machine...");
DebugOk marked this conversation as resolved.
Show resolved Hide resolved
species = null;
return "MobHuman";
}

var chance = component.HumanoidBaseChance + karmaBonus;

if (karma != null)
chance -= ((1 - component.HumanoidBaseChance) * (float) karma);

if (chance > 1 && _random.Prob(chance - 1))
{
species = oldSpecies;
return oldSpecies.Prototype;
}
else
chance = 1;

chance = Math.Clamp(chance, 0, 1);

if (_random.Prob(chance) &&
_prototypeManager.TryIndex<WeightedRandomPrototype>(MetempsychoticHumanoidPool, out var humanoidPool) &&
_prototypeManager.TryIndex<SpeciesPrototype>(humanoidPool.Pick(), out var speciesPrototype))
{
species = speciesPrototype;
return speciesPrototype.Prototype;
}
else
{
species = null;
_sawmill.Error("Could not index species for metempsychotic machine...");
return "MobHuman";
}
}
}
}
9 changes: 9 additions & 0 deletions Content.Shared/Humanoid/HumanoidAppearanceComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;
using Content.Shared.Preferences; //DeltaV, used for Metempsychosis, Fugitive, and Paradox Anomaly

namespace Content.Shared.Humanoid;

Expand Down Expand Up @@ -82,6 +83,14 @@ public sealed partial class HumanoidAppearanceComponent : Component
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
public Color? CachedFacialHairColor;

// Begin Nyano-code: allow paradox anomalies to be cloned.
/// <summary>
/// The last profile loaded onto this entity.
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
public HumanoidCharacterProfile? LastProfileLoaded;
DebugOk marked this conversation as resolved.
Show resolved Hide resolved
// End Nyano-code.
}

[DataDefinition]
Expand Down
4 changes: 4 additions & 0 deletions Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,10 @@ public virtual void LoadProfile(EntityUid uid, HumanoidCharacterProfile profile,

humanoid.Age = profile.Age;

// Begin Nyano-code: save the last profile for paradox anomalies.
humanoid.LastProfileLoaded = profile;
// End Nyano-code.

Dirty(humanoid);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
research-technology-psionic-countermeasures = Psionic Countermeasures
research-technology-teleportation = Teleportation
research-technology-metempsychosis = Metempsychosis
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@
- MailingUnitElectronics
- SalvageMagnetMachineCircuitboard
- StationMapElectronics
# - MetempsychoticMachineCircuitboard
- MetempsychoticMachineCircuitboard
- DeepFryerMachineCircuitboard
# End Nyano additions
- SalvageExpeditionsComputerCircuitboard # DeltaV
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
- type: entity
id: MetempsychoticMachineCircuitboard
parent: BaseMachineCircuitboard
name: metempsychotic machine machine board
description: A machine printed circuit board for a cloning pod
components:
- type: Sprite
state: medical
- type: MachineBoard
prototype: MetempsychoticMachine
requirements:
Capacitor: 2
Manipulator: 2
materialRequirements:
Glass: 1
Cable: 1
- type: ReverseEngineering
difficulty: 3
recipes:
- MetempsychoticMachineCircuitboard

- type: entity
id: ReverseEngineeringMachineCircuitboard
parent: BaseMachineCircuitboard
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
- type: entity
parent: CloningPod
id: MetempsychoticMachine
name: metempsychotic machine
description: Speeds along the transmigration of a soul to its next vessel.
components:
- type: MetempsychoticMachine
- type: CloningPod
- type: Machine
board: MetempsychoticMachineCircuitboard
- type: Sprite
sprite: Nyanotrasen/Structures/Machines/metempsychotic.rsi
snapCardinals: true
layers:
- state: pod_0
- type: Appearance
- type: GenericVisualizer
visuals:
enum.CloningPodVisuals.Status:
base:
Cloning: { state: pod_1 }
NoMind: { state: pod_1 }
Gore: { state: pod_1 }
Idle: { state: pod_0 }
- type: Psionic
DebugOk marked this conversation as resolved.
Show resolved Hide resolved
Loading
Loading