From 84d4c85b2fcadb0a5effe97ce81f718f6e73e850 Mon Sep 17 00:00:00 2001 From: BIGZi0348 Date: Wed, 1 Jan 2025 16:57:56 +0300 Subject: [PATCH 1/3] =?UTF-8?q?=D0=9D=D0=B0=D1=81=D1=80=D0=B0=D0=BB=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Xenoarchaeology/XenoArtifacts/ArtifactSystem.Nodes.cs | 2 +- .../Xenoarchaeology/XenoArtifacts/ArtifactSystem.cs | 4 ++-- .../_White/RandomArtifacts/RandomArtifactsSystem.cs | 6 +++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/ArtifactSystem.Nodes.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/ArtifactSystem.Nodes.cs index 9099d6d763..fd9e26aa15 100644 --- a/Content.Server/Xenoarchaeology/XenoArtifacts/ArtifactSystem.Nodes.cs +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/ArtifactSystem.Nodes.cs @@ -245,7 +245,7 @@ public sealed partial class ArtifactSystem /// WD. /// Generate an Artifact tree with fully developed nodes. /// - private void GenerateSafeArtifactNodeTree(EntityUid artifact, List allNodes, int nodesToCreate) + private void GenerateSafeArtifactNodeTree(EntityUid artifact, ref List allNodes, int nodesToCreate) { if (nodesToCreate < 1) { diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/ArtifactSystem.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/ArtifactSystem.cs index 253c42be03..927e9be321 100644 --- a/Content.Server/Xenoarchaeology/XenoArtifacts/ArtifactSystem.cs +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/ArtifactSystem.cs @@ -300,12 +300,12 @@ public sealed partial class ArtifactSystem : EntitySystem /// WD. Randomize a given artifact. /// [PublicAPI] - public void SafeRandomizeArtifact(EntityUid uid, ArtifactComponent component) + public void SafeRandomizeArtifact(EntityUid uid, ref ArtifactComponent component) { component.NodesMax = 5; var nodeAmount = _random.Next(component.NodesMin, component.NodesMax); - GenerateSafeArtifactNodeTree(uid, component.NodeTree, nodeAmount); + GenerateSafeArtifactNodeTree(uid, ref component.NodeTree, nodeAmount); var firstNode = GetRootNode(component.NodeTree); EnterNode(uid, ref firstNode, component); } diff --git a/Content.Server/_White/RandomArtifacts/RandomArtifactsSystem.cs b/Content.Server/_White/RandomArtifacts/RandomArtifactsSystem.cs index 782b54ca79..eb423842d7 100644 --- a/Content.Server/_White/RandomArtifacts/RandomArtifactsSystem.cs +++ b/Content.Server/_White/RandomArtifacts/RandomArtifactsSystem.cs @@ -8,6 +8,7 @@ using Content.Shared.Stacks; using Content.Shared.Item; using Robust.Shared.Configuration; using Robust.Shared.Random; +using Robust.Server.GameObjects; namespace Content.Server._White.RandomArtifacts; @@ -61,8 +62,11 @@ public sealed class RandomArtifactsSystem : EntitySystem if (HasComp(entity)) continue; + if (HasComp(entity)) + continue; + var artifactComponent = EnsureComp(entity); - _artifactsSystem.SafeRandomizeArtifact(entity, artifactComponent); + _artifactsSystem.SafeRandomizeArtifact(entity, ref artifactComponent); EnsureComp(entity); } From 12eb0b5308c3a6a2f36245c14dc1af91bd8eaeff Mon Sep 17 00:00:00 2001 From: BIGZi0348 Date: Wed, 1 Jan 2025 19:34:11 +0300 Subject: [PATCH 2/3] =?UTF-8?q?=D0=95=D1=89=D1=91=20=D0=B1=D0=BE=D0=BB?= =?UTF-8?q?=D1=8C=D1=88=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../XenoArtifacts/ArtifactSystem.Nodes.cs | 12 +++++++--- .../XenoArtifacts/ArtifactSystem.cs | 1 - .../RandomArtifactComponent.cs | 12 ++++++++++ .../RandomArtifactSystem.cs | 22 +++++++++++++++++ .../RandomArtifacts/RandomArtifactsSystem.cs | 24 ++++++++++++++++--- Content.Shared/_White/WhiteCVars.cs | 2 +- .../XenoArch/Effects/normal_effects.yml | 1 - 7 files changed, 65 insertions(+), 9 deletions(-) create mode 100644 Content.Server/_White/RandomArtifactDesc/RandomArtifactComponent.cs create mode 100644 Content.Server/_White/RandomArtifactDesc/RandomArtifactSystem.cs diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/ArtifactSystem.Nodes.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/ArtifactSystem.Nodes.cs index fd9e26aa15..aba68fdd1d 100644 --- a/Content.Server/Xenoarchaeology/XenoArtifacts/ArtifactSystem.Nodes.cs +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/ArtifactSystem.Nodes.cs @@ -264,7 +264,7 @@ public sealed partial class ArtifactSystem uninitializedNodes.Remove(node); node.Trigger = GetRandomTrigger(artifact, ref node); - node.Effect = GetSafeRandomEffect(artifact, ref node); + node.Effect = GetRandomEffect(artifact, ref node); var maxChildren = _random.Next(1, MaxEdgesPerNode - 1); @@ -285,18 +285,24 @@ public sealed partial class ArtifactSystem allNodes.Add(node); } + + foreach (var item in allNodes) + { + if (item.Depth <= 3) + item.Effect = GetSafeRandomEffect(artifact, item.Depth); + } } /// /// WD. /// - private string GetSafeRandomEffect(EntityUid artifact, ref ArtifactNode node) + private string GetSafeRandomEffect(EntityUid artifact, int nodeDepth) { var allEffects = _prototype.EnumeratePrototypes() .Where(x => (x.Whitelist?.IsValid(artifact, EntityManager) ?? true) && (!x.Blacklist?.IsValid(artifact, EntityManager) ?? true) && x.Safe).ToList(); var validDepth = allEffects.Select(x => x.TargetDepth).Distinct().ToList(); - var weights = GetDepthWeights(validDepth, node.Depth); + var weights = GetDepthWeights(validDepth, nodeDepth); var selectedRandomTargetDepth = GetRandomTargetDepth(weights); var targetEffects = allEffects .Where(x => x.TargetDepth == selectedRandomTargetDepth).ToList(); diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/ArtifactSystem.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/ArtifactSystem.cs index 927e9be321..7a3fc1610b 100644 --- a/Content.Server/Xenoarchaeology/XenoArtifacts/ArtifactSystem.cs +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/ArtifactSystem.cs @@ -302,7 +302,6 @@ public sealed partial class ArtifactSystem : EntitySystem [PublicAPI] public void SafeRandomizeArtifact(EntityUid uid, ref ArtifactComponent component) { - component.NodesMax = 5; var nodeAmount = _random.Next(component.NodesMin, component.NodesMax); GenerateSafeArtifactNodeTree(uid, ref component.NodeTree, nodeAmount); diff --git a/Content.Server/_White/RandomArtifactDesc/RandomArtifactComponent.cs b/Content.Server/_White/RandomArtifactDesc/RandomArtifactComponent.cs new file mode 100644 index 0000000000..4f8dfc9837 --- /dev/null +++ b/Content.Server/_White/RandomArtifactDesc/RandomArtifactComponent.cs @@ -0,0 +1,12 @@ +namespace Content.Server._White.RandomArtifactDesc +{ + /// + /// WD. + /// Добавляет описание предмету. + /// + [RegisterComponent] + public sealed partial class RandomArtifactDescComponent : Component + { + + } +} diff --git a/Content.Server/_White/RandomArtifactDesc/RandomArtifactSystem.cs b/Content.Server/_White/RandomArtifactDesc/RandomArtifactSystem.cs new file mode 100644 index 0000000000..e224ef6076 --- /dev/null +++ b/Content.Server/_White/RandomArtifactDesc/RandomArtifactSystem.cs @@ -0,0 +1,22 @@ +using Content.Shared.Examine; + +namespace Content.Server._White.RandomArtifactDesc; + +public sealed class RandomArtifactDescSystem : EntitySystem +{ + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnExamined); + } + + private void OnExamined(EntityUid uid, RandomArtifactDescComponent component, ExaminedEvent args) + { + if (args.IsInDetailsRange) + { + args.PushMarkup("С этим предметом что-то не так."); + } + } + +} diff --git a/Content.Server/_White/RandomArtifacts/RandomArtifactsSystem.cs b/Content.Server/_White/RandomArtifacts/RandomArtifactsSystem.cs index eb423842d7..69053520ad 100644 --- a/Content.Server/_White/RandomArtifacts/RandomArtifactsSystem.cs +++ b/Content.Server/_White/RandomArtifacts/RandomArtifactsSystem.cs @@ -2,6 +2,7 @@ using Content.Server.Station.Components; using Content.Server.Station.Systems; using Content.Server.Xenoarchaeology.XenoArtifacts; +using Content.Server._White.RandomArtifactDesc; using Content.Shared._White; using Content.Shared.Damage; using Content.Shared.Stacks; @@ -9,6 +10,8 @@ using Content.Shared.Item; using Robust.Shared.Configuration; using Robust.Shared.Random; using Robust.Server.GameObjects; +using Content.Shared.Body.Organ; +using Content.Shared.Body.Part; namespace Content.Server._White.RandomArtifacts; @@ -18,6 +21,7 @@ public sealed class RandomArtifactsSystem : EntitySystem [Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly IConfigurationManager _configurationManager = default!; [Dependency] private readonly StationSystem _station = default!; + [Dependency] private readonly IComponentFactory _componentFactory = default!; private float _itemToArtifactRatio; // from 0 to 100. In % percents. Default is 0.4% private bool _artifactsEnabled; @@ -65,9 +69,19 @@ public sealed class RandomArtifactsSystem : EntitySystem if (HasComp(entity)) continue; - var artifactComponent = EnsureComp(entity); - _artifactsSystem.SafeRandomizeArtifact(entity, ref artifactComponent); + if (HasComp(entity)) + continue; + if (HasComp(entity)) + continue; + + // var artifactComponent = EnsureComp(entity); + var comp = (ArtifactComponent) _componentFactory.GetComponent("Artifact"); + comp.Owner = entity; + _artifactsSystem.SafeRandomizeArtifact(entity, ref comp); + AddComp(entity, comp); + + EnsureComp(entity); EnsureComp(entity); } } @@ -87,7 +101,11 @@ public sealed class RandomArtifactsSystem : EntitySystem foreach (var (_, artifact) in items) { - RemComp(artifact.Owner); + if (HasComp(artifact.Owner)) + { + RemComp(artifact.Owner); + RemComp(artifact.Owner); + } } } diff --git a/Content.Shared/_White/WhiteCVars.cs b/Content.Shared/_White/WhiteCVars.cs index 851d84167c..332c7e7db3 100644 --- a/Content.Shared/_White/WhiteCVars.cs +++ b/Content.Shared/_White/WhiteCVars.cs @@ -418,7 +418,7 @@ public sealed class WhiteCVars CVarDef.Create("white.random_artifacts_enabled", true, CVar.SERVERONLY); public static readonly CVarDef ItemToArtifactRatio = - CVarDef.Create("white.random_artifacts_ratio", 0.4f, CVar.SERVERONLY); + CVarDef.Create("white.random_artifacts_ratio", 10.4f, CVar.SERVERONLY); public static readonly CVarDef ACWebhook = CVarDef.Create("ac.webhook", "", CVar.SERVERONLY); diff --git a/Resources/Prototypes/XenoArch/Effects/normal_effects.yml b/Resources/Prototypes/XenoArch/Effects/normal_effects.yml index db3240dc4b..2e255badbb 100644 --- a/Resources/Prototypes/XenoArch/Effects/normal_effects.yml +++ b/Resources/Prototypes/XenoArch/Effects/normal_effects.yml @@ -124,7 +124,6 @@ id: EffectBananaSpawn targetDepth: 0 effectHint: artifact-effect-hint-creation - safe: true # WD components: - type: SpawnArtifact maxSpawns: 20 From ccdcd00f54f7afe352b982159dd05497b3ff8b1f Mon Sep 17 00:00:00 2001 From: BIGZi0348 Date: Wed, 1 Jan 2025 19:34:38 +0300 Subject: [PATCH 3/3] =?UTF-8?q?=D0=9D=D0=B5=20=D1=82=D0=B0=D0=BA=20=D0=BC?= =?UTF-8?q?=D0=BD=D0=BE=D0=B3=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Content.Shared/_White/WhiteCVars.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Content.Shared/_White/WhiteCVars.cs b/Content.Shared/_White/WhiteCVars.cs index 332c7e7db3..851d84167c 100644 --- a/Content.Shared/_White/WhiteCVars.cs +++ b/Content.Shared/_White/WhiteCVars.cs @@ -418,7 +418,7 @@ public sealed class WhiteCVars CVarDef.Create("white.random_artifacts_enabled", true, CVar.SERVERONLY); public static readonly CVarDef ItemToArtifactRatio = - CVarDef.Create("white.random_artifacts_ratio", 10.4f, CVar.SERVERONLY); + CVarDef.Create("white.random_artifacts_ratio", 0.4f, CVar.SERVERONLY); public static readonly CVarDef ACWebhook = CVarDef.Create("ac.webhook", "", CVar.SERVERONLY);