Переработка рандомных артефактов
This commit is contained in:
@@ -30,7 +30,7 @@ public sealed partial class ArtifactSystem
|
|||||||
|
|
||||||
_usedNodeIds.Clear();
|
_usedNodeIds.Clear();
|
||||||
|
|
||||||
var uninitializedNodes = new List<ArtifactNode> { new(){ Id = GetValidNodeId() } };
|
var uninitializedNodes = new List<ArtifactNode> { new() { Id = GetValidNodeId() } };
|
||||||
var createdNodes = 1;
|
var createdNodes = 1;
|
||||||
|
|
||||||
while (uninitializedNodes.Count > 0)
|
while (uninitializedNodes.Count > 0)
|
||||||
@@ -50,7 +50,7 @@ public sealed partial class ArtifactSystem
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
var child = new ArtifactNode {Id = GetValidNodeId(), Depth = node.Depth + 1};
|
var child = new ArtifactNode { Id = GetValidNodeId(), Depth = node.Depth + 1 };
|
||||||
node.Edges.Add(child.Id);
|
node.Edges.Add(child.Id);
|
||||||
child.Edges.Add(node.Id);
|
child.Edges.Add(node.Id);
|
||||||
|
|
||||||
@@ -240,4 +240,67 @@ public sealed partial class ArtifactSystem
|
|||||||
{
|
{
|
||||||
return nodes.First(x => x.Id == id);
|
return nodes.First(x => x.Id == id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// WD.
|
||||||
|
/// Generate an Artifact tree with fully developed nodes.
|
||||||
|
/// </summary>
|
||||||
|
private void GenerateSafeArtifactNodeTree(EntityUid artifact, List<ArtifactNode> allNodes, int nodesToCreate)
|
||||||
|
{
|
||||||
|
if (nodesToCreate < 1)
|
||||||
|
{
|
||||||
|
Log.Error($"nodesToCreate {nodesToCreate} is less than 1. Aborting artifact tree generation.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_usedNodeIds.Clear();
|
||||||
|
|
||||||
|
var uninitializedNodes = new List<ArtifactNode> { new() { Id = GetValidNodeId() } };
|
||||||
|
var createdNodes = 1;
|
||||||
|
|
||||||
|
while (uninitializedNodes.Count > 0)
|
||||||
|
{
|
||||||
|
var node = uninitializedNodes[0];
|
||||||
|
uninitializedNodes.Remove(node);
|
||||||
|
|
||||||
|
node.Trigger = GetRandomTrigger(artifact, ref node);
|
||||||
|
node.Effect = GetSafeRandomEffect(artifact, ref node);
|
||||||
|
|
||||||
|
var maxChildren = _random.Next(1, MaxEdgesPerNode - 1);
|
||||||
|
|
||||||
|
for (var i = 0; i < maxChildren; i++)
|
||||||
|
{
|
||||||
|
if (nodesToCreate <= createdNodes)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
var child = new ArtifactNode { Id = GetValidNodeId(), Depth = node.Depth + 1 };
|
||||||
|
node.Edges.Add(child.Id);
|
||||||
|
child.Edges.Add(node.Id);
|
||||||
|
|
||||||
|
uninitializedNodes.Add(child);
|
||||||
|
createdNodes++;
|
||||||
|
}
|
||||||
|
|
||||||
|
allNodes.Add(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// WD.
|
||||||
|
/// </summary>
|
||||||
|
private string GetSafeRandomEffect(EntityUid artifact, ref ArtifactNode node)
|
||||||
|
{
|
||||||
|
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 selectedRandomTargetDepth = GetRandomTargetDepth(weights);
|
||||||
|
var targetEffects = allEffects
|
||||||
|
.Where(x => x.TargetDepth == selectedRandomTargetDepth).ToList();
|
||||||
|
|
||||||
|
return _random.Pick(targetEffects).ID;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -295,4 +295,18 @@ public sealed partial class ArtifactSystem : EntitySystem
|
|||||||
{
|
{
|
||||||
return allNodes.First(n => n.Depth == 0);
|
return allNodes.First(n => n.Depth == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// WD. Randomize a given artifact.
|
||||||
|
/// </summary>
|
||||||
|
[PublicAPI]
|
||||||
|
public void SafeRandomizeArtifact(EntityUid uid, ArtifactComponent component)
|
||||||
|
{
|
||||||
|
component.NodesMax = 5;
|
||||||
|
var nodeAmount = _random.Next(component.NodesMin, component.NodesMax);
|
||||||
|
|
||||||
|
GenerateSafeArtifactNodeTree(uid, component.NodeTree, nodeAmount);
|
||||||
|
var firstNode = GetRootNode(component.NodeTree);
|
||||||
|
EnterNode(uid, ref firstNode, component);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ using Content.Server.Station.Components;
|
|||||||
using Content.Server.Station.Systems;
|
using Content.Server.Station.Systems;
|
||||||
using Content.Server.Xenoarchaeology.XenoArtifacts;
|
using Content.Server.Xenoarchaeology.XenoArtifacts;
|
||||||
using Content.Shared._White;
|
using Content.Shared._White;
|
||||||
|
using Content.Shared.Damage;
|
||||||
|
using Content.Shared.Stacks;
|
||||||
using Content.Shared.Item;
|
using Content.Shared.Item;
|
||||||
using Robust.Shared.Configuration;
|
using Robust.Shared.Configuration;
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
@@ -16,7 +18,7 @@ public sealed class RandomArtifactsSystem : EntitySystem
|
|||||||
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
|
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
|
||||||
[Dependency] private readonly StationSystem _station = default!;
|
[Dependency] private readonly StationSystem _station = default!;
|
||||||
|
|
||||||
private float _itemToArtifactRatio; // from 0 to 100. In % percents. Default is 0.7%
|
private float _itemToArtifactRatio; // from 0 to 100. In % percents. Default is 0.4%
|
||||||
private bool _artifactsEnabled;
|
private bool _artifactsEnabled;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
@@ -34,11 +36,12 @@ public sealed class RandomArtifactsSystem : EntitySystem
|
|||||||
if (!_artifactsEnabled)
|
if (!_artifactsEnabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Removing old artifact-items and replace it with new funny stealthy items
|
// No we don't
|
||||||
foreach (var oldArtifact in EntityQuery<ArtifactComponent>())
|
// // Removing old artifact-items and replace it with new funny stealthy items
|
||||||
{
|
// foreach (var oldArtifact in EntityQuery<ArtifactComponent>())
|
||||||
QueueDel(oldArtifact.Owner);
|
// {
|
||||||
}
|
// QueueDel(oldArtifact.Owner);
|
||||||
|
// }
|
||||||
|
|
||||||
var items = EntityQuery<ItemComponent>().ToList();
|
var items = EntityQuery<ItemComponent>().ToList();
|
||||||
_random.Shuffle(items);
|
_random.Shuffle(items);
|
||||||
@@ -55,8 +58,13 @@ public sealed class RandomArtifactsSystem : EntitySystem
|
|||||||
if (!HasComp<StationDataComponent>(station))
|
if (!HasComp<StationDataComponent>(station))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (HasComp<StackComponent>(entity))
|
||||||
|
continue;
|
||||||
|
|
||||||
var artifactComponent = EnsureComp<ArtifactComponent>(entity);
|
var artifactComponent = EnsureComp<ArtifactComponent>(entity);
|
||||||
_artifactsSystem.RandomizeArtifact(entity, artifactComponent);
|
_artifactsSystem.SafeRandomizeArtifact(entity, artifactComponent);
|
||||||
|
|
||||||
|
EnsureComp<DamageableComponent>(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,4 +41,10 @@ public sealed partial class ArtifactEffectPrototype : IPrototype
|
|||||||
|
|
||||||
[DataField("blacklist")]
|
[DataField("blacklist")]
|
||||||
public EntityWhitelist? Blacklist;
|
public EntityWhitelist? Blacklist;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// WD. Is it safe for random items?
|
||||||
|
/// </summary>
|
||||||
|
[DataField]
|
||||||
|
public bool Safe = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
id: EffectBadFeeling
|
id: EffectBadFeeling
|
||||||
targetDepth: 0
|
targetDepth: 0
|
||||||
effectHint: artifact-effect-hint-mental
|
effectHint: artifact-effect-hint-mental
|
||||||
|
safe: true # WD
|
||||||
components:
|
components:
|
||||||
- type: TelepathicArtifact
|
- type: TelepathicArtifact
|
||||||
messages:
|
messages:
|
||||||
@@ -32,6 +33,7 @@
|
|||||||
id: EffectGoodFeeling
|
id: EffectGoodFeeling
|
||||||
targetDepth: 0
|
targetDepth: 0
|
||||||
effectHint: artifact-effect-hint-mental
|
effectHint: artifact-effect-hint-mental
|
||||||
|
safe: true # WD
|
||||||
components:
|
components:
|
||||||
- type: TelepathicArtifact
|
- type: TelepathicArtifact
|
||||||
messages:
|
messages:
|
||||||
@@ -61,6 +63,7 @@
|
|||||||
id: EffectJunkSpawn
|
id: EffectJunkSpawn
|
||||||
targetDepth: 0
|
targetDepth: 0
|
||||||
effectHint: artifact-effect-hint-creation
|
effectHint: artifact-effect-hint-creation
|
||||||
|
safe: true # WD
|
||||||
components:
|
components:
|
||||||
- type: SpawnArtifact
|
- type: SpawnArtifact
|
||||||
maxSpawns: 10
|
maxSpawns: 10
|
||||||
@@ -100,12 +103,14 @@
|
|||||||
id: EffectLightFlicker
|
id: EffectLightFlicker
|
||||||
targetDepth: 0
|
targetDepth: 0
|
||||||
effectHint: artifact-effect-hint-electrical-interference
|
effectHint: artifact-effect-hint-electrical-interference
|
||||||
|
safe: true # WD
|
||||||
components:
|
components:
|
||||||
- type: LightFlickerArtifact
|
- type: LightFlickerArtifact
|
||||||
|
|
||||||
- type: artifactEffect
|
- type: artifactEffect
|
||||||
id: EffectPointLight
|
id: EffectPointLight
|
||||||
targetDepth: 0
|
targetDepth: 0
|
||||||
|
safe: true # WD
|
||||||
components:
|
components:
|
||||||
- type: PointLight
|
- type: PointLight
|
||||||
radius: 8
|
radius: 8
|
||||||
@@ -119,6 +124,7 @@
|
|||||||
id: EffectBananaSpawn
|
id: EffectBananaSpawn
|
||||||
targetDepth: 0
|
targetDepth: 0
|
||||||
effectHint: artifact-effect-hint-creation
|
effectHint: artifact-effect-hint-creation
|
||||||
|
safe: true # WD
|
||||||
components:
|
components:
|
||||||
- type: SpawnArtifact
|
- type: SpawnArtifact
|
||||||
maxSpawns: 20
|
maxSpawns: 20
|
||||||
@@ -137,6 +143,7 @@
|
|||||||
id: EffectFloraSpawn
|
id: EffectFloraSpawn
|
||||||
targetDepth: 1
|
targetDepth: 1
|
||||||
effectHint: artifact-effect-hint-creation
|
effectHint: artifact-effect-hint-creation
|
||||||
|
safe: true # WD
|
||||||
components:
|
components:
|
||||||
- type: SpawnArtifact
|
- type: SpawnArtifact
|
||||||
maxSpawns: 3
|
maxSpawns: 3
|
||||||
@@ -186,6 +193,7 @@
|
|||||||
id: EffectCold
|
id: EffectCold
|
||||||
targetDepth: 1
|
targetDepth: 1
|
||||||
effectHint: artifact-effect-hint-consumption
|
effectHint: artifact-effect-hint-consumption
|
||||||
|
safe: true # WD
|
||||||
components:
|
components:
|
||||||
- type: TemperatureArtifact
|
- type: TemperatureArtifact
|
||||||
targetTemp: 50
|
targetTemp: 50
|
||||||
@@ -221,6 +229,7 @@
|
|||||||
id: EffectInstrumentSpawn
|
id: EffectInstrumentSpawn
|
||||||
targetDepth: 1
|
targetDepth: 1
|
||||||
effectHint: artifact-effect-hint-creation
|
effectHint: artifact-effect-hint-creation
|
||||||
|
safe: true # WD
|
||||||
components:
|
components:
|
||||||
- type: SpawnArtifact
|
- type: SpawnArtifact
|
||||||
maxSpawns: 5
|
maxSpawns: 5
|
||||||
@@ -231,6 +240,7 @@
|
|||||||
id: EffectMonkeySpawn
|
id: EffectMonkeySpawn
|
||||||
targetDepth: 1
|
targetDepth: 1
|
||||||
effectHint: artifact-effect-hint-creation
|
effectHint: artifact-effect-hint-creation
|
||||||
|
safe: true # WD
|
||||||
components:
|
components:
|
||||||
- type: SpawnArtifact
|
- type: SpawnArtifact
|
||||||
spawns:
|
spawns:
|
||||||
@@ -245,6 +255,7 @@
|
|||||||
id: EffectChargeBatteries
|
id: EffectChargeBatteries
|
||||||
targetDepth: 1
|
targetDepth: 1
|
||||||
effectHint: artifact-effect-hint-release
|
effectHint: artifact-effect-hint-release
|
||||||
|
safe: true # WD
|
||||||
components:
|
components:
|
||||||
- type: ChargeBatteryArtifact
|
- type: ChargeBatteryArtifact
|
||||||
- type: TelepathicArtifact
|
- type: TelepathicArtifact
|
||||||
@@ -264,6 +275,7 @@
|
|||||||
id: EffectKnock
|
id: EffectKnock
|
||||||
targetDepth: 1
|
targetDepth: 1
|
||||||
effectHint: artifact-effect-hint-electrical-interference
|
effectHint: artifact-effect-hint-electrical-interference
|
||||||
|
safe: true # WD
|
||||||
components:
|
components:
|
||||||
- type: KnockArtifact
|
- type: KnockArtifact
|
||||||
|
|
||||||
@@ -291,6 +303,7 @@
|
|||||||
id: EffectInvisibility
|
id: EffectInvisibility
|
||||||
targetDepth: 2
|
targetDepth: 2
|
||||||
effectHint: artifact-effect-hint-visual
|
effectHint: artifact-effect-hint-visual
|
||||||
|
safe: true # WD
|
||||||
components:
|
components:
|
||||||
- type: Stealth
|
- type: Stealth
|
||||||
hadOutline: true
|
hadOutline: true
|
||||||
@@ -317,6 +330,7 @@
|
|||||||
id: EffectRareMaterialSpawn
|
id: EffectRareMaterialSpawn
|
||||||
targetDepth: 2
|
targetDepth: 2
|
||||||
effectHint: artifact-effect-hint-creation
|
effectHint: artifact-effect-hint-creation
|
||||||
|
safe: true # WD
|
||||||
components:
|
components:
|
||||||
- type: SpawnArtifact
|
- type: SpawnArtifact
|
||||||
spawns:
|
spawns:
|
||||||
@@ -414,6 +428,7 @@
|
|||||||
id: EffectCashSpawn
|
id: EffectCashSpawn
|
||||||
targetDepth: 2
|
targetDepth: 2
|
||||||
effectHint: artifact-effect-hint-creation
|
effectHint: artifact-effect-hint-creation
|
||||||
|
safe: true # WD
|
||||||
components:
|
components:
|
||||||
- type: SpawnArtifact
|
- type: SpawnArtifact
|
||||||
maxSpawns: 10
|
maxSpawns: 10
|
||||||
@@ -461,6 +476,7 @@
|
|||||||
id: EffectBlink
|
id: EffectBlink
|
||||||
targetDepth: 2
|
targetDepth: 2
|
||||||
effectHint: artifact-effect-hint-displacement
|
effectHint: artifact-effect-hint-displacement
|
||||||
|
safe: true # WD
|
||||||
components:
|
components:
|
||||||
- type: RandomTeleportArtifact
|
- type: RandomTeleportArtifact
|
||||||
|
|
||||||
@@ -592,6 +608,7 @@
|
|||||||
id: EffectHealAll
|
id: EffectHealAll
|
||||||
targetDepth: 3
|
targetDepth: 3
|
||||||
effectHint: artifact-effect-hint-environment
|
effectHint: artifact-effect-hint-environment
|
||||||
|
safe: true # WD
|
||||||
components:
|
components:
|
||||||
- type: DamageNearbyArtifact
|
- type: DamageNearbyArtifact
|
||||||
damageChance: 1
|
damageChance: 1
|
||||||
@@ -617,6 +634,7 @@
|
|||||||
id: EffectMaterialSpawn
|
id: EffectMaterialSpawn
|
||||||
targetDepth: 3
|
targetDepth: 3
|
||||||
effectHint: artifact-effect-hint-creation
|
effectHint: artifact-effect-hint-creation
|
||||||
|
safe: true # WD
|
||||||
components:
|
components:
|
||||||
- type: SpawnArtifact
|
- type: SpawnArtifact
|
||||||
maxSpawns: 5
|
maxSpawns: 5
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
id: EffectIntercom
|
id: EffectIntercom
|
||||||
targetDepth: 2
|
targetDepth: 2
|
||||||
effectHint: artifact-effect-hint-communication
|
effectHint: artifact-effect-hint-communication
|
||||||
|
safe: true # WD
|
||||||
permanentComponents:
|
permanentComponents:
|
||||||
- type: RadioMicrophone
|
- type: RadioMicrophone
|
||||||
powerRequired: false
|
powerRequired: false
|
||||||
@@ -31,6 +32,7 @@
|
|||||||
id: EffectRandomInstrument
|
id: EffectRandomInstrument
|
||||||
targetDepth: 2
|
targetDepth: 2
|
||||||
effectHint: artifact-effect-hint-mental
|
effectHint: artifact-effect-hint-mental
|
||||||
|
safe: true # WD
|
||||||
permanentComponents:
|
permanentComponents:
|
||||||
- type: Instrument
|
- type: Instrument
|
||||||
- type: ActivatableUI
|
- type: ActivatableUI
|
||||||
@@ -43,6 +45,7 @@
|
|||||||
id: EffectStorage
|
id: EffectStorage
|
||||||
targetDepth: 2
|
targetDepth: 2
|
||||||
effectHint: artifact-effect-hint-storage
|
effectHint: artifact-effect-hint-storage
|
||||||
|
safe: true # WD
|
||||||
whitelist:
|
whitelist:
|
||||||
components:
|
components:
|
||||||
- Item # it doesnt necessarily have to be restricted from structures, but i think it'll be better that way
|
- Item # it doesnt necessarily have to be restricted from structures, but i think it'll be better that way
|
||||||
@@ -62,6 +65,7 @@
|
|||||||
id: EffectPhasing
|
id: EffectPhasing
|
||||||
targetDepth: 2
|
targetDepth: 2
|
||||||
effectHint: artifact-effect-hint-phasing
|
effectHint: artifact-effect-hint-phasing
|
||||||
|
safe: true # WD
|
||||||
permanentComponents:
|
permanentComponents:
|
||||||
- type: PhasingArtifact
|
- type: PhasingArtifact
|
||||||
|
|
||||||
@@ -83,6 +87,7 @@
|
|||||||
id: EffectSolutionStorage
|
id: EffectSolutionStorage
|
||||||
targetDepth: 2
|
targetDepth: 2
|
||||||
effectHint: artifact-effect-hint-storage
|
effectHint: artifact-effect-hint-storage
|
||||||
|
safe: true # WD
|
||||||
whitelist:
|
whitelist:
|
||||||
components:
|
components:
|
||||||
- Item
|
- Item
|
||||||
@@ -112,6 +117,7 @@
|
|||||||
id: EffectSpeedUp
|
id: EffectSpeedUp
|
||||||
targetDepth: 2
|
targetDepth: 2
|
||||||
effectHint: artifact-effect-hint-displacement
|
effectHint: artifact-effect-hint-displacement
|
||||||
|
safe: true # WD
|
||||||
whitelist:
|
whitelist:
|
||||||
components:
|
components:
|
||||||
- Item
|
- Item
|
||||||
@@ -124,6 +130,7 @@
|
|||||||
id: EffectDrill
|
id: EffectDrill
|
||||||
targetDepth: 3
|
targetDepth: 3
|
||||||
effectHint: artifact-effect-hint-drill
|
effectHint: artifact-effect-hint-drill
|
||||||
|
safe: true # WD
|
||||||
whitelist:
|
whitelist:
|
||||||
components:
|
components:
|
||||||
- Item
|
- Item
|
||||||
@@ -142,6 +149,7 @@
|
|||||||
id: EffectPowerGen20K
|
id: EffectPowerGen20K
|
||||||
targetDepth: 3
|
targetDepth: 3
|
||||||
effectHint: artifact-effect-hint-release
|
effectHint: artifact-effect-hint-release
|
||||||
|
safe: true # WD
|
||||||
blacklist:
|
blacklist:
|
||||||
components:
|
components:
|
||||||
- Item
|
- Item
|
||||||
@@ -159,6 +167,7 @@
|
|||||||
id: EffectBigIron
|
id: EffectBigIron
|
||||||
targetDepth: 3
|
targetDepth: 3
|
||||||
effectHint: artifact-effect-hint-gun
|
effectHint: artifact-effect-hint-gun
|
||||||
|
safe: true # WD
|
||||||
whitelist:
|
whitelist:
|
||||||
components:
|
components:
|
||||||
- Item
|
- Item
|
||||||
@@ -192,6 +201,7 @@
|
|||||||
id: EffectSentience
|
id: EffectSentience
|
||||||
targetDepth: 3
|
targetDepth: 3
|
||||||
effectHint: artifact-effect-hint-sentience
|
effectHint: artifact-effect-hint-sentience
|
||||||
|
safe: true # WD
|
||||||
permanentComponents:
|
permanentComponents:
|
||||||
- type: GhostRole
|
- type: GhostRole
|
||||||
allowMovement: true
|
allowMovement: true
|
||||||
@@ -208,6 +218,7 @@
|
|||||||
id: EffectMultitool
|
id: EffectMultitool
|
||||||
targetDepth: 3
|
targetDepth: 3
|
||||||
effectHint: artifact-effect-hint-multitool
|
effectHint: artifact-effect-hint-multitool
|
||||||
|
safe: true # WD
|
||||||
whitelist:
|
whitelist:
|
||||||
components:
|
components:
|
||||||
- Item
|
- Item
|
||||||
|
|||||||
Reference in New Issue
Block a user