Наконец-то смешное: артефакты теперь рандомные предметы на станции (#654)
* funny random artifacts * cvar logic * ratio logic moved to cvars * funny update
This commit is contained in:
@@ -25,13 +25,13 @@ public sealed partial class ArtifactComponent : Component
|
|||||||
/// Minimum number of nodes to generate, inclusive
|
/// Minimum number of nodes to generate, inclusive
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField("nodesMin")]
|
[DataField("nodesMin")]
|
||||||
public int NodesMin = 3;
|
public int NodesMin = 2;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Maximum number of nodes to generate, exclusive
|
/// Maximum number of nodes to generate, exclusive
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField("nodesMax")]
|
[DataField("nodesMax")]
|
||||||
public int NodesMax = 9;
|
public int NodesMax = 10;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
using Content.Server.Administration;
|
using Content.Server.Administration;
|
||||||
using Content.Shared.Administration;
|
using Content.Shared.Administration;
|
||||||
using Robust.Shared.Console;
|
using Robust.Shared.Console;
|
||||||
@@ -17,6 +18,10 @@ public partial class ArtifactSystem
|
|||||||
|
|
||||||
_conHost.RegisterCommand("getartifactmaxvalue", "Reports the maximum research point value for a given artifact", "forceartifacteffect <uid>",
|
_conHost.RegisterCommand("getartifactmaxvalue", "Reports the maximum research point value for a given artifact", "forceartifacteffect <uid>",
|
||||||
GetArtifactMaxValue);
|
GetArtifactMaxValue);
|
||||||
|
|
||||||
|
// WD added
|
||||||
|
_conHost.RegisterCommand("listartifacts", "List all artifact ids and names", "forceartifacteffect",
|
||||||
|
ListArtifacts);
|
||||||
}
|
}
|
||||||
|
|
||||||
[AdminCommand(AdminFlags.Fun)]
|
[AdminCommand(AdminFlags.Fun)]
|
||||||
@@ -68,4 +73,25 @@ public partial class ArtifactSystem
|
|||||||
var pointSum = GetResearchPointValue(uid.Value, artifact, true);
|
var pointSum = GetResearchPointValue(uid.Value, artifact, true);
|
||||||
shell.WriteLine($"Max point value for {ToPrettyString(uid.Value)} with {artifact.NodeTree.Count} nodes: {pointSum}");
|
shell.WriteLine($"Max point value for {ToPrettyString(uid.Value)} with {artifact.NodeTree.Count} nodes: {pointSum}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// WD added - start
|
||||||
|
[AdminCommand(AdminFlags.Admin)]
|
||||||
|
private void ListArtifacts(IConsoleShell shell, string argstr, string[] args)
|
||||||
|
{
|
||||||
|
var items = EntityQuery<ArtifactComponent>();
|
||||||
|
|
||||||
|
var msg = new StringBuilder();
|
||||||
|
|
||||||
|
foreach (var artifact in items)
|
||||||
|
{
|
||||||
|
var entity = artifact.Owner;
|
||||||
|
var effects = string.Join(", ", artifact.NodeTree.ToArray().Select(x => x.Effect));
|
||||||
|
|
||||||
|
msg.AppendFormat("{0}: {1}, {2}\n\n", Name(entity), effects, entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
shell.WriteLine(msg.ToString());
|
||||||
|
}
|
||||||
|
// WD added - end
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,84 @@
|
|||||||
|
using System.Linq;
|
||||||
|
using Content.Server.Xenoarchaeology.XenoArtifacts;
|
||||||
|
using Content.Shared._White;
|
||||||
|
using Content.Shared.GameTicking;
|
||||||
|
using Content.Shared.Item;
|
||||||
|
using Robust.Shared.Configuration;
|
||||||
|
using Robust.Shared.Random;
|
||||||
|
|
||||||
|
namespace Content.Server._White.RandomArtifacts;
|
||||||
|
|
||||||
|
public sealed class RandomArtifactsSystem : EntitySystem
|
||||||
|
{
|
||||||
|
[Dependency] private readonly ArtifactSystem _artifactsSystem = default!;
|
||||||
|
[Dependency] private readonly IRobustRandom _random = default!;
|
||||||
|
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
|
||||||
|
|
||||||
|
private float _itemToArtifactRatio; // from 0 to 100. In % percents. Default is 0.7%
|
||||||
|
private bool _artifactsEnabled;
|
||||||
|
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
base.Initialize();
|
||||||
|
|
||||||
|
_configurationManager.OnValueChanged(WhiteCVars.EnableRandomArtifacts, b => OnCvarChanged(b), true);
|
||||||
|
_configurationManager.OnValueChanged(WhiteCVars.ItemToArtifactRatio, r => _itemToArtifactRatio = r, true);
|
||||||
|
|
||||||
|
SubscribeLocalEvent<RoundStartedEvent>(OnRoundStart);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnRoundStart(RoundStartedEvent ev)
|
||||||
|
{
|
||||||
|
if (!_artifactsEnabled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Removing old artifact-items and replace it with new funny stealthy items
|
||||||
|
foreach (var oldArtifact in EntityQuery<ArtifactComponent>())
|
||||||
|
{
|
||||||
|
QueueDel(oldArtifact.Owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
var items = EntityQuery<ItemComponent>().ToList();
|
||||||
|
_random.Shuffle(items);
|
||||||
|
|
||||||
|
var selectedItems = GetPercentageOfHashSet(items, _itemToArtifactRatio);
|
||||||
|
|
||||||
|
foreach (var item in selectedItems)
|
||||||
|
{
|
||||||
|
var entity = item.Owner;
|
||||||
|
|
||||||
|
var artifactComponent = EnsureComp<ArtifactComponent>(entity);
|
||||||
|
_artifactsSystem.RandomizeArtifact(entity, artifactComponent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private HashSet<ItemComponent> GetPercentageOfHashSet(List<ItemComponent> sourceList, float percentage)
|
||||||
|
{
|
||||||
|
var countToAdd = (int) Math.Round((double) sourceList.Count * percentage / 100);
|
||||||
|
|
||||||
|
return sourceList.Where(x => !Transform(x.Owner).Anchored).Take(countToAdd).ToHashSet();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnCvarChanged(bool enabled)
|
||||||
|
{
|
||||||
|
if (_artifactsEnabled != enabled && !enabled)
|
||||||
|
{
|
||||||
|
var items = EntityQuery<ItemComponent, ArtifactComponent>();
|
||||||
|
|
||||||
|
foreach (var (_, artifact) in items)
|
||||||
|
{
|
||||||
|
RemComp<ArtifactComponent>(artifact.Owner);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_artifactsEnabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Number of items on maps
|
||||||
|
DEV - 1527
|
||||||
|
WhiteBox - 13692
|
||||||
|
WonderBox - 15306
|
||||||
|
*/
|
||||||
@@ -402,4 +402,14 @@ public sealed class WhiteCVars
|
|||||||
|
|
||||||
public static readonly CVarDef<string> TimeTrackerApiKey =
|
public static readonly CVarDef<string> TimeTrackerApiKey =
|
||||||
CVarDef.Create("white.time_tracker_key", "", CVar.SERVERONLY | CVar.CONFIDENTIAL | CVar.ARCHIVE);
|
CVarDef.Create("white.time_tracker_key", "", CVar.SERVERONLY | CVar.CONFIDENTIAL | CVar.ARCHIVE);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Random Artifacts
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static readonly CVarDef<bool> EnableRandomArtifacts =
|
||||||
|
CVarDef.Create("white.random_artifacts_enabled", true, CVar.SERVERONLY);
|
||||||
|
|
||||||
|
public static readonly CVarDef<float> ItemToArtifactRatio =
|
||||||
|
CVarDef.Create("white.random_artifacts_ratio", 0.7f, CVar.SERVERONLY);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -129,18 +129,6 @@
|
|||||||
revertOnDeath: true
|
revertOnDeath: true
|
||||||
duration: 20
|
duration: 20
|
||||||
|
|
||||||
- type: polymorph
|
|
||||||
id: ArtifactCluwne
|
|
||||||
configuration:
|
|
||||||
entity: MobCluwne
|
|
||||||
forced: true
|
|
||||||
transferName: true
|
|
||||||
transferHumanoidAppearance: true
|
|
||||||
inventory: None
|
|
||||||
revertOnDeath: true
|
|
||||||
revertOnCrit: true
|
|
||||||
duration: 30
|
|
||||||
|
|
||||||
- type: polymorph
|
- type: polymorph
|
||||||
id: ArtifactLizard
|
id: ArtifactLizard
|
||||||
configuration:
|
configuration:
|
||||||
@@ -449,4 +437,58 @@
|
|||||||
inventory: None
|
inventory: None
|
||||||
revertOnDeath: true
|
revertOnDeath: true
|
||||||
revertOnCrit: true
|
revertOnCrit: true
|
||||||
duration: 20
|
duration: 60
|
||||||
|
|
||||||
|
- type: polymorph # WD
|
||||||
|
id: ArtifactWallDoor
|
||||||
|
configuration:
|
||||||
|
entity: WoodDoor
|
||||||
|
forced: true
|
||||||
|
inventory: None
|
||||||
|
transferName: false
|
||||||
|
transferDamage: false
|
||||||
|
revertOnCrit: true
|
||||||
|
revertOnDeath: true
|
||||||
|
duration: 120
|
||||||
|
|
||||||
|
- type: polymorph # WD
|
||||||
|
id: ArtifactCluwne
|
||||||
|
configuration:
|
||||||
|
entity: MobCluwne
|
||||||
|
forced: true
|
||||||
|
transferName: true
|
||||||
|
transferHumanoidAppearance: true
|
||||||
|
inventory: Transfer
|
||||||
|
revertOnCrit: false
|
||||||
|
revertOnDeath: false
|
||||||
|
duration: 240
|
||||||
|
|
||||||
|
- type: polymorph # WD
|
||||||
|
id: ArtifactMouse
|
||||||
|
configuration:
|
||||||
|
entity: MobMouse
|
||||||
|
forced: true
|
||||||
|
inventory: Drop
|
||||||
|
revertOnCrit: true
|
||||||
|
revertOnDeath: true
|
||||||
|
duration: 60
|
||||||
|
|
||||||
|
- type: polymorph # WD
|
||||||
|
id: ArtifactChicken
|
||||||
|
configuration:
|
||||||
|
entity: MobChicken
|
||||||
|
forced: true
|
||||||
|
inventory: Drop
|
||||||
|
revertOnCrit: true
|
||||||
|
revertOnDeath: true
|
||||||
|
duration: 60
|
||||||
|
|
||||||
|
- type: polymorph # WD
|
||||||
|
id: ArtifactGnome
|
||||||
|
configuration:
|
||||||
|
entity: MobGnome
|
||||||
|
forced: true
|
||||||
|
inventory: Drop
|
||||||
|
revertOnCrit: true
|
||||||
|
revertOnDeath: true
|
||||||
|
duration: 240
|
||||||
|
|||||||
@@ -479,6 +479,19 @@
|
|||||||
- Dexalin
|
- Dexalin
|
||||||
- Omnizine
|
- Omnizine
|
||||||
|
|
||||||
|
- type: artifactEffect # WD
|
||||||
|
id: EffectChemicalPuddleWaterPotassium
|
||||||
|
targetDepth: 2
|
||||||
|
effectHint: artifact-effect-hint-biochemical
|
||||||
|
components:
|
||||||
|
- type: ChemicalPuddleArtifact
|
||||||
|
chemicalSolution:
|
||||||
|
maxVol: 500
|
||||||
|
canReact: true
|
||||||
|
possibleChemicals:
|
||||||
|
- Water
|
||||||
|
- Potassium
|
||||||
|
|
||||||
- type: artifactEffect
|
- type: artifactEffect
|
||||||
id: EffectChemicalPuddleRare
|
id: EffectChemicalPuddleRare
|
||||||
targetDepth: 2
|
targetDepth: 2
|
||||||
@@ -535,6 +548,46 @@
|
|||||||
- type: PolyOthersArtifact
|
- type: PolyOthersArtifact
|
||||||
polymorphPrototypeName: ArtifactLuminous
|
polymorphPrototypeName: ArtifactLuminous
|
||||||
|
|
||||||
|
- type: artifactEffect # WD
|
||||||
|
id: EffectPolyWallDoor
|
||||||
|
targetDepth: 3
|
||||||
|
effectHint: artifact-effect-hint-polymorph
|
||||||
|
components:
|
||||||
|
- type: PolyOthersArtifact
|
||||||
|
polymorphPrototypeName: ArtifactWallDoor
|
||||||
|
|
||||||
|
- type: artifactEffect # WD
|
||||||
|
id: EffectPolyCluwne
|
||||||
|
targetDepth: 3
|
||||||
|
effectHint: artifact-effect-hint-polymorph
|
||||||
|
components:
|
||||||
|
- type: PolyOthersArtifact
|
||||||
|
polymorphPrototypeName: ArtifactCluwne
|
||||||
|
|
||||||
|
- type: artifactEffect # WD
|
||||||
|
id: EffectPolyMouse
|
||||||
|
targetDepth: 3
|
||||||
|
effectHint: artifact-effect-hint-polymorph
|
||||||
|
components:
|
||||||
|
- type: PolyOthersArtifact
|
||||||
|
polymorphPrototypeName: ArtifactMouse
|
||||||
|
|
||||||
|
- type: artifactEffect # WD
|
||||||
|
id: EffectPolyChicken
|
||||||
|
targetDepth: 3
|
||||||
|
effectHint: artifact-effect-hint-polymorph
|
||||||
|
components:
|
||||||
|
- type: PolyOthersArtifact
|
||||||
|
polymorphPrototypeName: ArtifactChicken
|
||||||
|
|
||||||
|
- type: artifactEffect # WD
|
||||||
|
id: EffectPolyGnome
|
||||||
|
targetDepth: 3
|
||||||
|
effectHint: artifact-effect-hint-polymorph
|
||||||
|
components:
|
||||||
|
- type: PolyOthersArtifact
|
||||||
|
polymorphPrototypeName: ArtifactGnome
|
||||||
|
|
||||||
- type: artifactEffect
|
- type: artifactEffect
|
||||||
id: EffectHealAll
|
id: EffectHealAll
|
||||||
targetDepth: 3
|
targetDepth: 3
|
||||||
@@ -582,7 +635,7 @@
|
|||||||
components:
|
components:
|
||||||
- type: ShuffleArtifact
|
- type: ShuffleArtifact
|
||||||
- type: TelepathicArtifact
|
- type: TelepathicArtifact
|
||||||
range: 7.5
|
range: 12
|
||||||
messages:
|
messages:
|
||||||
- shuffle-artifact-popup
|
- shuffle-artifact-popup
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user