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