Ещё больше
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// WD.
|
||||
/// </summary>
|
||||
private string GetSafeRandomEffect(EntityUid artifact, ref ArtifactNode node)
|
||||
private string GetSafeRandomEffect(EntityUid artifact, int nodeDepth)
|
||||
{
|
||||
var allEffects = _prototype.EnumeratePrototypes<ArtifactEffectPrototype>()
|
||||
.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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace Content.Server._White.RandomArtifactDesc
|
||||
{
|
||||
/// <summary>
|
||||
/// WD.
|
||||
/// Добавляет описание предмету.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public sealed partial class RandomArtifactDescComponent : Component
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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<RandomArtifactDescComponent, ExaminedEvent>(OnExamined);
|
||||
}
|
||||
|
||||
private void OnExamined(EntityUid uid, RandomArtifactDescComponent component, ExaminedEvent args)
|
||||
{
|
||||
if (args.IsInDetailsRange)
|
||||
{
|
||||
args.PushMarkup("С этим предметом что-то не так.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<PointLightComponent>(entity))
|
||||
continue;
|
||||
|
||||
var artifactComponent = EnsureComp<ArtifactComponent>(entity);
|
||||
_artifactsSystem.SafeRandomizeArtifact(entity, ref artifactComponent);
|
||||
if (HasComp<OrganComponent>(entity))
|
||||
continue;
|
||||
|
||||
if (HasComp<BodyPartComponent>(entity))
|
||||
continue;
|
||||
|
||||
// var artifactComponent = EnsureComp<ArtifactComponent>(entity);
|
||||
var comp = (ArtifactComponent) _componentFactory.GetComponent("Artifact");
|
||||
comp.Owner = entity;
|
||||
_artifactsSystem.SafeRandomizeArtifact(entity, ref comp);
|
||||
AddComp(entity, comp);
|
||||
|
||||
EnsureComp<RandomArtifactDescComponent>(entity);
|
||||
EnsureComp<DamageableComponent>(entity);
|
||||
}
|
||||
}
|
||||
@@ -87,7 +101,11 @@ public sealed class RandomArtifactsSystem : EntitySystem
|
||||
|
||||
foreach (var (_, artifact) in items)
|
||||
{
|
||||
RemComp<ArtifactComponent>(artifact.Owner);
|
||||
if (HasComp<RandomArtifactDescComponent>(artifact.Owner))
|
||||
{
|
||||
RemComp<ArtifactComponent>(artifact.Owner);
|
||||
RemComp<RandomArtifactDescComponent>(artifact.Owner);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -418,7 +418,7 @@ public sealed class WhiteCVars
|
||||
CVarDef.Create("white.random_artifacts_enabled", true, CVar.SERVERONLY);
|
||||
|
||||
public static readonly CVarDef<float> 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<string> ACWebhook =
|
||||
CVarDef.Create("ac.webhook", "", CVar.SERVERONLY);
|
||||
|
||||
@@ -124,7 +124,6 @@
|
||||
id: EffectBananaSpawn
|
||||
targetDepth: 0
|
||||
effectHint: artifact-effect-hint-creation
|
||||
safe: true # WD
|
||||
components:
|
||||
- type: SpawnArtifact
|
||||
maxSpawns: 20
|
||||
|
||||
Reference in New Issue
Block a user